/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import BusinessLogic.MedicineBL;
import BusinessLogic.MyQueryBL;
import BusinessLogic.PatientBL;
import BusinessLogic.PrescriptionBL;
import BusinessLogic.TreatmentBL;
import BusinessLogic.WorkerBL;
import Ch.Elca.Iiop.GenericUserException;
import Model.CustomDataType.CMDateTime;
import Model.CustomDataType._CMDateTimeStub;
import Model.Medicine.Medicine;
import Model.Patient;
import Model.Prescription;
import Model.Sex;
import Model.Treatment;
import Model.TreatmentDetail;
import Model.Worker;
import Model._PatientStub;
import corba.CorbaConnection;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.JTextComponent;
import org.jdesktop.swingx.JXComboBox;
import org.jdesktop.swingx.JXTable;

/**
 *
 * @author Do, Paul
 */
public class MainForm extends javax.swing.JFrame {

    public static final int SEX = 0;
    public static final int MED_STATUS = 1;
    public static final int MED_DETAIL_STATUS = 2;
    public static final int PAY_STATUS = 3;
    public static final int TREATMENT_STATUS = 4;
    public static final int WORKER_STATUS = 5;
    public static final int WORKER_GROUP = 6;
    private CorbaConnection corbaConnection;
    private PatientBL patientBL;
    private MyQueryBL myQueryBL;
    private TreatmentBL treatmentBL;
    private PrescriptionBL prescriptionBL;
    private MedicineBL medicineBL;
    private WorkerBL workerBL;

    /**
     * Creates new form MainForm
     */
    public MainForm() {
        initComponents();
        initMyEvents();
        ImageIcon icon = new ImageIcon(getClass().getResource("/images/Red-Cross-icon.png"));
        setIconImage(icon.getImage());
    }

    public MainForm(CorbaConnection cc) {
        this.corbaConnection = cc;
        patientBL = (PatientBL) corbaConnection.getRemoteObject("PatientBL", PatientBL.class);
        myQueryBL = (MyQueryBL) corbaConnection.getRemoteObject("MyQueryBL", MyQueryBL.class);
        treatmentBL = (TreatmentBL) corbaConnection.getRemoteObject("TreatmentBL", TreatmentBL.class);
        prescriptionBL = (PrescriptionBL) corbaConnection.getRemoteObject("PrescriptionBL",
                PrescriptionBL.class);
        medicineBL = (MedicineBL) corbaConnection.getRemoteObject("MedicineBL", MedicineBL.class);
        workerBL = (WorkerBL) corbaConnection.getRemoteObject("WorkerBL", WorkerBL.class);
        initComponents();
        initMyEvents();
        ImageIcon icon = new ImageIcon(getClass().getResource("/images/Nurse-icon.png"));
        setIconImage(icon.getImage());
        
        //Remove tab
        tabParent.remove(TiepNhan);
        tabParent.remove(HoSoBenhAn);
        tabParent.remove(KhaiBaoToaMau);
        tabParent.remove(KhaiBaoVatTu);
        tabParent.remove(PhanQuyen);
        tabParent.remove(ChuanDoanBenh);
        tabParent.remove(NhanVienBacSy);
        tabParent.remove(NhapKho);
        tabParent.remove(ThanhToan);
        tabParent.remove(BaoCaoDoanhThu);
    }

    public void fillDataOnPatientTable(JXTable table, Patient[] p) throws GenericUserException {
        String[] colName = new String[]{"Mã bệnh nhân", "Họ tên", "Năm sinh",
            "CMND", "Giới tính", "Địa chỉ"};
        Object[] rowData = null;
        DefaultTableModel model = new DefaultTableModel(colName, 0);
        if (p == null) {
            table.setModel(model);
            return;
        }
        for (int i = 0; i < p.length; i++) {
            Sex s = p[i].getSex();
            String sex = (s == Sex.Sex_NONE ? "Chưa cập nhật"
                    : (s == Sex.Sex_MALE ? "Nam" : "Nữ"));
            rowData = new Object[]{p[i].getPatientId(), p[i].getFullName(),
                p[i].getDateOfBirth().toShortDateString(), p[i].getIdCard(),
                sex, p[i].getAddress()};
            model.addRow(rowData);
        }
        table.setModel(model);
    }

    public void fillDataOnTableFromArray(JXTable table, String[] data,
            String[] colNames, Hashtable<Integer, Integer> options, boolean isRawArray) {
        Object[] rowData = null;
        DefaultTableModel model = new DefaultTableModel(colNames, 0);
        if (data == null) {
            table.setModel(model);
            return;
        }
        if (options == null) {
            if (isRawArray) {
                for (int i = 0; i < data.length; i++) {
                    String value = data[i];
                    String[] values = value.split("<<_>>");
                    rowData = new Object[values.length];
                    for (int j = 0; j < values.length; j++) {
                        rowData[j] = values[j];
                    }
                    model.addRow(rowData);
                }
            } else {
                for (int i = 0; i < data.length; i++) {
                    rowData = new Object[]{data[i]};
                    model.addRow(rowData);
                }
            }
        } else {
            for (int i = 0; i < data.length; i++) {
                String value = data[i];
                String[] values = value.split("<<_>>");
                rowData = new Object[values.length];
                for (int j = 0; j < values.length; j++) {
                    String realVal = "";
                    if (checkIndexExist(j, options)) {
                        int type = options.get(j);
                        int col = Integer.parseInt(values[j]);
                        switch (type) {
                            case SEX:
                                realVal = col == 0 ? "Chưa cập nhật"
                                        : (col == 1 ? "Nam" : "Nữ");
                                break;
                            case MED_STATUS:
                                realVal = col == 0 ? "Hết bán" : "Còn bán";
                                break;
                            case MED_DETAIL_STATUS:
                                realVal = col == 0 ? "Hết bán" : "Còn bán";
                                break;
                            case WORKER_STATUS:
                                realVal = col == 0 ? "Đã nghỉ làm" : "Đang làm";
                                break;
                            case PAY_STATUS:
                                realVal = col == 0 ? "Chưa thanh toán" : "Đã thanh toán";
                                break;
                            case TREATMENT_STATUS:
                                realVal = col == 1 ? "Chờ khám"
                                        : (col == 2 ? "Đang khám" : "Đã khám");
                                break;
                            case WORKER_GROUP:
                                realVal = col == 1 ? "Bác sĩ"
                                        : ((col == 2) ? "Nhân viên nhà thuốc"
                                        : (col == 3 ? "Y tá" : "Quản lý"));
                                break;
                            default:
                                realVal = "NULL";
                        }
                        rowData[j] = realVal;
                        continue;
                    }
                    rowData[j] = values[j];
                }
                model.addRow(rowData);
            }
        }
        table.setModel(model);
    }

    private boolean checkIndexExist(int index, Hashtable<Integer, Integer> table) {
        return table.containsKey(index);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TabMenuBar = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        lbTiepNhan = new javax.swing.JLabel();
        jXTitledPanel1 = new org.jdesktop.swingx.JXTitledPanel();
        jToolBar2 = new javax.swing.JToolBar();
        jPanel15 = new javax.swing.JPanel();
        lbBenhAn = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jXTitledPanel2 = new org.jdesktop.swingx.JXTitledPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jPanel5 = new javax.swing.JPanel();
        lbDanhMuc = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lbBaoCao = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jXTitledPanel3 = new org.jdesktop.swingx.JXTitledPanel();
        lbThanhToan = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        lbNhapKho = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jToolBar3 = new javax.swing.JToolBar();
        jPanel6 = new javax.swing.JPanel();
        lbCauHinh = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jXTitledPanel4 = new org.jdesktop.swingx.JXTitledPanel();
        jToolBar4 = new javax.swing.JToolBar();
        jPanel11 = new javax.swing.JPanel();
        lbThoat = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jXTitledPanel7 = new org.jdesktop.swingx.JXTitledPanel();
        jToolBar5 = new javax.swing.JToolBar();
        jPanel14 = new javax.swing.JPanel();
        tabParent = new javax.swing.JTabbedPane();
        DangNhap = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel53 = new javax.swing.JLabel();
        panelLogin = new javax.swing.JPanel();
        jLabel54 = new javax.swing.JLabel();
        jLabel55 = new javax.swing.JLabel();
        jLabel56 = new javax.swing.JLabel();
        txtUserName = new javax.swing.JTextField();
        btnDangNhap = new javax.swing.JButton();
        txtPassword = new javax.swing.JPasswordField();
        TiepNhan = new javax.swing.JPanel();
        jXTitledPanel5 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel12 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtPatientIdReception = new javax.swing.JTextField();
        txtPatientNameReception = new javax.swing.JTextField();
        txtPatientAgeReception = new javax.swing.JTextField();
        txtPatientWeightReception = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        txtPatientIdCardReception = new javax.swing.JTextField();
        txtPatientAddressReception = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        txtPatientPhoneReception = new javax.swing.JTextField();
        txtPatientRelativeReception = new javax.swing.JTextField();
        cbbPatientSexReception = new javax.swing.JComboBox();
        btnRegisterReception = new javax.swing.JButton();
        datePickerDOB = new org.jdesktop.swingx.JXDatePicker();
        btnRefreshReception = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        datePickerTreatment = new org.jdesktop.swingx.JXDatePicker();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblPatients = new org.jdesktop.swingx.JXTable();
        btnReTreatmentReception = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        btnSearchPa = new javax.swing.JButton();
        txtSearchPaId = new javax.swing.JTextField();
        txtSearchPaName = new javax.swing.JTextField();
        txtSearchPaYear = new javax.swing.JTextField();
        cbbSearchPaSex = new javax.swing.JComboBox();
        txtSearchPaIdCard = new javax.swing.JTextField();
        HoSoBenhAn = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        txtTreatmentSearchPaName = new javax.swing.JTextField();
        txtTreatmentSearchPaYear = new javax.swing.JTextField();
        cbbTreatmentSearchPaSex = new javax.swing.JComboBox();
        txtTreatmentSearchPaIdCard = new javax.swing.JTextField();
        dpTreatmentSearchPaDOT = new org.jdesktop.swingx.JXDatePicker();
        btnTreatmentSearchPa = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        jLabel44 = new javax.swing.JLabel();
        jLabel45 = new javax.swing.JLabel();
        jLabel46 = new javax.swing.JLabel();
        txtTreatmentId = new javax.swing.JTextField();
        txtTreatmentPaName = new javax.swing.JTextField();
        cbbTreatmentPaSex = new javax.swing.JComboBox();
        txtTreatmentPaDOB = new javax.swing.JTextField();
        txtTreatmentPaAddress = new javax.swing.JTextField();
        txtTreatmentPaPhone = new javax.swing.JTextField();
        txtTreatmentPaRelative = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel47 = new javax.swing.JLabel();
        jLabel48 = new javax.swing.JLabel();
        jLabel49 = new javax.swing.JLabel();
        txtTreatmentSymptom = new javax.swing.JTextField();
        txtTreatmentAdvice = new javax.swing.JTextField();
        cbbTreatmentDiagnosis = new javax.swing.JComboBox();
        jLabel50 = new javax.swing.JLabel();
        jLabel51 = new javax.swing.JLabel();
        jLabel52 = new javax.swing.JLabel();
        dpTreatmentDOReT = new org.jdesktop.swingx.JXDatePicker();
        cbbTreatmentPrescription = new javax.swing.JComboBox();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblTreatmentPrescription = new org.jdesktop.swingx.JXTable();
        btnTreatmentSave = new javax.swing.JButton();
        btnTreatmentPrint = new javax.swing.JButton();
        cbbTreatmentDayOfUsingMed = new javax.swing.JComboBox();
        jLabel27 = new javax.swing.JLabel();
        txtTreatmentCost = new javax.swing.JLabel();
        txtTreatmentMedCost = new javax.swing.JLabel();
        btnTreatmentMedCost = new javax.swing.JButton();
        jXTitledPanel6 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel10 = new javax.swing.JPanel();
        jLabel39 = new javax.swing.JLabel();
        cbbTreatmentStatus = new javax.swing.JComboBox();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblTreatmentPatients = new org.jdesktop.swingx.JXTable();
        KhaiBaoVatTu = new javax.swing.JPanel();
        jXTitledPanel8 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel17 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel57 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        jButton6 = new javax.swing.JButton();
        jPanel18 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jXTable1 = new org.jdesktop.swingx.JXTable();
        jPanel19 = new javax.swing.JPanel();
        jLabel58 = new javax.swing.JLabel();
        jTextField6 = new javax.swing.JTextField();
        jLabel59 = new javax.swing.JLabel();
        jTextField7 = new javax.swing.JTextField();
        jLabel61 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jLabel62 = new javax.swing.JLabel();
        jTextField9 = new javax.swing.JTextField();
        jLabel83 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel84 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jLabel85 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        jScrollPane5 = new javax.swing.JScrollPane();
        jXTable2 = new org.jdesktop.swingx.JXTable();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        ChuanDoanBenh = new javax.swing.JPanel();
        jXTitledPanel14 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel21 = new javax.swing.JPanel();
        jLabel60 = new javax.swing.JLabel();
        txtDiagnosisName = new org.jdesktop.swingx.JXTextField();
        btnDiagnosisSave = new javax.swing.JButton();
        btnDiagnosisUpdate = new javax.swing.JButton();
        jLabel114 = new javax.swing.JLabel();
        jTextField20 = new javax.swing.JTextField();
        jPanel22 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        tblDiagnosis = new org.jdesktop.swingx.JXTable();
        NhanVienBacSy = new javax.swing.JPanel();
        jXTitledPanel16 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel25 = new javax.swing.JPanel();
        jLabel63 = new javax.swing.JLabel();
        jLabel64 = new javax.swing.JLabel();
        jLabel65 = new javax.swing.JLabel();
        jLabel66 = new javax.swing.JLabel();
        jLabel67 = new javax.swing.JLabel();
        txtWorkerId = new org.jdesktop.swingx.JXTextField();
        txtWorkerName = new org.jdesktop.swingx.JXTextField();
        txtWorkerYear = new org.jdesktop.swingx.JXTextField();
        cbbWorkerStatus = new javax.swing.JComboBox();
        cbbWorkerGroup = new javax.swing.JComboBox();
        btnWorkerSearch = new javax.swing.JButton();
        jPanel26 = new javax.swing.JPanel();
        jScrollPane10 = new javax.swing.JScrollPane();
        tblWorkerSearchResult = new org.jdesktop.swingx.JXTable();
        jPanel27 = new javax.swing.JPanel();
        jLabel68 = new javax.swing.JLabel();
        jLabel69 = new javax.swing.JLabel();
        jLabel70 = new javax.swing.JLabel();
        jLabel71 = new javax.swing.JLabel();
        txtWorkerMainId = new org.jdesktop.swingx.JXTextField();
        txtWorkerMainName = new org.jdesktop.swingx.JXTextField();
        cbbWorkerMainSex = new javax.swing.JComboBox();
        jLabel72 = new javax.swing.JLabel();
        jLabel73 = new javax.swing.JLabel();
        txtWorkerMainAddress = new org.jdesktop.swingx.JXTextField();
        txtWorkerMainPhone = new org.jdesktop.swingx.JXTextField();
        jLabel74 = new javax.swing.JLabel();
        txtWorkerMainIdCard = new org.jdesktop.swingx.JXTextField();
        jLabel75 = new javax.swing.JLabel();
        jLabel76 = new javax.swing.JLabel();
        txtWorkerMainUser = new org.jdesktop.swingx.JXTextField();
        jLabel77 = new javax.swing.JLabel();
        txtWorkerMainPass = new org.jdesktop.swingx.JXTextField();
        jLabel78 = new javax.swing.JLabel();
        cbbWorkerMainStatus = new javax.swing.JComboBox();
        btnWorkerMainNew = new javax.swing.JButton();
        btnWorkerMainUpdate = new javax.swing.JButton();
        btnWorkerMainSave = new javax.swing.JButton();
        jPanel32 = new javax.swing.JPanel();
        jScrollPane11 = new javax.swing.JScrollPane();
        tblWorkerMain = new org.jdesktop.swingx.JXTable();
        dpWorkerMainDOB = new org.jdesktop.swingx.JXDatePicker();
        cbbWorkerMainGroup = new javax.swing.JComboBox();
        KhaiBaoToaMau = new javax.swing.JPanel();
        jXTitledPanel17 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel28 = new javax.swing.JPanel();
        jScrollPane12 = new javax.swing.JScrollPane();
        jXTable10 = new org.jdesktop.swingx.JXTable();
        jPanel29 = new javax.swing.JPanel();
        jLabel79 = new javax.swing.JLabel();
        jLabel80 = new javax.swing.JLabel();
        jLabel81 = new javax.swing.JLabel();
        jXTextField23 = new org.jdesktop.swingx.JXTextField();
        jXTextField24 = new org.jdesktop.swingx.JXTextField();
        jXTextField25 = new org.jdesktop.swingx.JXTextField();
        jLabel82 = new javax.swing.JLabel();
        jScrollPane13 = new javax.swing.JScrollPane();
        jXTable11 = new org.jdesktop.swingx.JXTable();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        BaoCaoDoanhThu = new javax.swing.JPanel();
        jXTitledPanel9 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel34 = new javax.swing.JPanel();
        jScrollPane15 = new javax.swing.JScrollPane();
        jXTable6 = new org.jdesktop.swingx.JXTable();
        jLabel112 = new javax.swing.JLabel();
        jXDatePicker2 = new org.jdesktop.swingx.JXDatePicker();
        jLabel113 = new javax.swing.JLabel();
        jXDatePicker3 = new org.jdesktop.swingx.JXDatePicker();
        jButton18 = new javax.swing.JButton();
        PhanQuyen = new javax.swing.JPanel();
        jXTitledPanel10 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel30 = new javax.swing.JPanel();
        jLabel86 = new javax.swing.JLabel();
        jLabel87 = new javax.swing.JLabel();
        jTextField10 = new javax.swing.JTextField();
        jTextField11 = new javax.swing.JTextField();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jLabel88 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jXTable3 = new org.jdesktop.swingx.JXTable();
        jPanel31 = new javax.swing.JPanel();
        jLabel89 = new javax.swing.JLabel();
        jComboBox6 = new javax.swing.JComboBox();
        jLabel90 = new javax.swing.JLabel();
        jPanel20 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        jXTree1 = new org.jdesktop.swingx.JXTree();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        ThanhToan = new javax.swing.JPanel();
        jPanel23 = new javax.swing.JPanel();
        jLabel91 = new javax.swing.JLabel();
        jLabel92 = new javax.swing.JLabel();
        jLabel93 = new javax.swing.JLabel();
        jLabel94 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jTextField12 = new javax.swing.JTextField();
        jTextField13 = new javax.swing.JTextField();
        jComboBox7 = new javax.swing.JComboBox();
        jLabel95 = new javax.swing.JLabel();
        jTextField14 = new javax.swing.JTextField();
        jLabel96 = new javax.swing.JLabel();
        jXDatePicker1 = new org.jdesktop.swingx.JXDatePicker();
        jLabel97 = new javax.swing.JLabel();
        jComboBox8 = new javax.swing.JComboBox();
        jButton15 = new javax.swing.JButton();
        jPanel24 = new javax.swing.JPanel();
        jLabel98 = new javax.swing.JLabel();
        jComboBox9 = new javax.swing.JComboBox();
        jScrollPane7 = new javax.swing.JScrollPane();
        jXTable4 = new org.jdesktop.swingx.JXTable();
        jPanel33 = new javax.swing.JPanel();
        jLabel99 = new javax.swing.JLabel();
        jTextField15 = new javax.swing.JTextField();
        jLabel100 = new javax.swing.JLabel();
        jTextField16 = new javax.swing.JTextField();
        jLabel101 = new javax.swing.JLabel();
        jComboBox10 = new javax.swing.JComboBox();
        jLabel102 = new javax.swing.JLabel();
        jTextField17 = new javax.swing.JTextField();
        jLabel103 = new javax.swing.JLabel();
        jTextField18 = new javax.swing.JTextField();
        jLabel104 = new javax.swing.JLabel();
        jTextField19 = new javax.swing.JTextField();
        jLabel105 = new javax.swing.JLabel();
        jScrollPane14 = new javax.swing.JScrollPane();
        jXTable5 = new org.jdesktop.swingx.JXTable();
        jCheckBox1 = new javax.swing.JCheckBox();
        jLabel106 = new javax.swing.JLabel();
        jLabel107 = new javax.swing.JLabel();
        jLabel108 = new javax.swing.JLabel();
        jLabel109 = new javax.swing.JLabel();
        jLabel110 = new javax.swing.JLabel();
        jLabel111 = new javax.swing.JLabel();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        NhapKho = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Phần Mềm Quản Lý Phòng Mạch Tư 2.0");
        setBackground(new java.awt.Color(255, 255, 255));
        setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        setType(java.awt.Window.Type.POPUP);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        TabMenuBar.setToolTipText("");
        TabMenuBar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        TabMenuBar.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        TabMenuBar.setName(""); // NOI18N
        TabMenuBar.setPreferredSize(new java.awt.Dimension(1000, 138));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Y Tá", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Times New Roman", 0, 12), new java.awt.Color(204, 204, 204))); // NOI18N
        jPanel3.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jLabel1.setText("Tiếp Nhận");
        jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lbTiepNhan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Content_32x32.png"))); // NOI18N
        lbTiepNhan.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbTiepNhan.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbTiepNhanMouseClicked(evt);
            }
        });

        jXTitledPanel1.setBackground(new java.awt.Color(204, 204, 204));
        jXTitledPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel1.setForeground(new java.awt.Color(204, 204, 204));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(lbTiepNhan)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jXTitledPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(lbTiepNhan, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jXTitledPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jToolBar2.setBackground(new java.awt.Color(255, 255, 255));
        jToolBar2.setRollover(true);
        jToolBar2.setEnabled(false);

        jPanel15.setBackground(new java.awt.Color(255, 255, 255));
        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Khám Bệnh", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, null, new java.awt.Color(204, 204, 204)));

        lbBenhAn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Doctor-icon.png"))); // NOI18N
        lbBenhAn.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbBenhAn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbBenhAnMouseClicked(evt);
            }
        });

        jLabel4.setText("Bệnh Án");

        jXTitledPanel2.setBackground(new java.awt.Color(204, 204, 204));
        jXTitledPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbBenhAn)
                    .addComponent(jLabel4))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jXTitledPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addComponent(lbBenhAn, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jXTitledPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33))
        );

        jToolBar2.add(jPanel15);

        jToolBar1.setBackground(new java.awt.Color(255, 255, 255));
        jToolBar1.setRollover(true);
        jToolBar1.setEnabled(false);

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Nhà Thuốc", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, null, new java.awt.Color(204, 204, 204)));

        lbDanhMuc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/category-icon.png"))); // NOI18N
        lbDanhMuc.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbDanhMuc.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbDanhMucMouseClicked(evt);
            }
        });

        jLabel6.setText("Danh Mục");

        lbBaoCao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/medical-report-icon.png"))); // NOI18N
        lbBaoCao.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbBaoCao.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbBaoCaoMouseClicked(evt);
            }
        });

        jLabel8.setText("Báo Cáo");

        jXTitledPanel3.setBackground(new java.awt.Color(204, 204, 204));
        jXTitledPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        lbThanhToan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Bill-icon.png"))); // NOI18N
        lbThanhToan.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbThanhToan.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbThanhToanMouseClicked(evt);
            }
        });

        jLabel29.setText("Thanh Toán");

        lbNhapKho.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Home-icon.png"))); // NOI18N
        lbNhapKho.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbNhapKho.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbNhapKhoMouseClicked(evt);
            }
        });

        jLabel31.setText("Nhập Kho");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbDanhMuc, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(lbBaoCao)
                .addGap(26, 26, 26)
                .addComponent(lbThanhToan, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lbNhapKho)
                .addContainerGap())
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel29)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel31)
                .addGap(0, 3, Short.MAX_VALUE))
            .addComponent(jXTitledPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbBaoCao, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
                    .addComponent(lbDanhMuc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbThanhToan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbNhapKho, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel8)
                    .addComponent(jLabel29)
                    .addComponent(jLabel31))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jXTitledPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6))
        );

        lbDanhMuc.getAccessibleContext().setAccessibleName("aaaa");

        jToolBar1.add(jPanel5);

        jToolBar3.setBackground(new java.awt.Color(255, 255, 255));
        jToolBar3.setRollover(true);
        jToolBar3.setEnabled(false);

        jPanel6.setBackground(new java.awt.Color(255, 255, 255));
        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Quản Trị", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, null, new java.awt.Color(204, 204, 204)));

        lbCauHinh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Settings-icon.png"))); // NOI18N
        lbCauHinh.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        jLabel10.setText("Cấu Hình");

        jXTitledPanel4.setBackground(new java.awt.Color(204, 204, 204));
        jXTitledPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbCauHinh)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jXTitledPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel10)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(lbCauHinh, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jXTitledPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6))
        );

        jToolBar3.add(jPanel6);

        jToolBar4.setBackground(new java.awt.Color(255, 255, 255));
        jToolBar4.setRollover(true);
        jToolBar4.setEnabled(false);

        jPanel11.setBackground(new java.awt.Color(255, 255, 255));
        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Thoát", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, null, new java.awt.Color(204, 204, 204)));

        lbThoat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Exit.png"))); // NOI18N
        lbThoat.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbThoat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbThoatMouseClicked(evt);
            }
        });

        jLabel33.setText("Thoát");

        jXTitledPanel7.setBackground(new java.awt.Color(204, 204, 204));
        jXTitledPanel7.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbThoat, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(13, Short.MAX_VALUE))
            .addComponent(jXTitledPanel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addComponent(lbThoat, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel33)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jXTitledPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32))
        );

        jToolBar4.add(jPanel11);

        jToolBar5.setBackground(new java.awt.Color(255, 255, 255));
        jToolBar5.setRollover(true);

        jPanel14.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 546, Short.MAX_VALUE)
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 105, Short.MAX_VALUE)
        );

        jToolBar5.add(jPanel14);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jToolBar3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jToolBar4, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jToolBar5, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jToolBar3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jToolBar4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        TabMenuBar.addTab("Chức năng", jPanel1);

        tabParent.setBackground(new java.awt.Color(255, 255, 255));
        tabParent.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
        tabParent.setOpaque(true);
        tabParent.setPreferredSize(new java.awt.Dimension(1117, 500));
        tabParent.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabParentMouseClicked(evt);
            }
        });

        DangNhap.setBackground(new java.awt.Color(255, 255, 255));

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Phòng Khám Đa Khoa Tuổi Trẻ Vui"));

        jLabel2.setIcon(new javax.swing.ImageIcon("D:\\QLPhongMachTu2.0\\QlpmJavaClient\\src\\images\\Nurse-icon.png")); // NOI18N

        jLabel3.setText("Địa chỉ:");

        jLabel5.setText("Điện thoại:");

        jLabel7.setText("Tân Lập - Đông Hòa - Dĩ An - Bình Dương");

        jLabel53.setText("0973 495 795");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel53, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel53)))
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelLogin.setBackground(new java.awt.Color(255, 255, 255));
        panelLogin.setBorder(javax.swing.BorderFactory.createTitledBorder("Đăng Nhập"));

        jLabel54.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/lock-icon.png"))); // NOI18N

        jLabel55.setText("Tài khoản:");

        jLabel56.setText("Mật khẩu:");

        txtUserName.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtUserNameKeyPressed(evt);
            }
        });

        btnDangNhap.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Organizer_16x16.png"))); // NOI18N
        btnDangNhap.setText("Đăng Nhập");
        btnDangNhap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDangNhapActionPerformed(evt);
            }
        });

        txtPassword.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtPasswordKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout panelLoginLayout = new javax.swing.GroupLayout(panelLogin);
        panelLogin.setLayout(panelLoginLayout);
        panelLoginLayout.setHorizontalGroup(
            panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLoginLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel54)
                .addGap(31, 31, 31)
                .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel56)
                    .addComponent(jLabel55))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtUserName)
                    .addComponent(txtPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE))
                .addGap(10, 10, 10))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLoginLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnDangNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panelLoginLayout.setVerticalGroup(
            panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLoginLayout.createSequentialGroup()
                .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelLoginLayout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel55)
                            .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel56)))
                    .addGroup(panelLoginLayout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jLabel54)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnDangNhap)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout DangNhapLayout = new javax.swing.GroupLayout(DangNhap);
        DangNhap.setLayout(DangNhapLayout);
        DangNhapLayout.setHorizontalGroup(
            DangNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DangNhapLayout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 139, Short.MAX_VALUE)
                .addComponent(panelLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(51, 51, 51))
        );
        DangNhapLayout.setVerticalGroup(
            DangNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DangNhapLayout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(DangNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(panelLogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(337, Short.MAX_VALUE))
        );

        tabParent.addTab("Đăng nhập", DangNhap);

        TiepNhan.setBackground(new java.awt.Color(255, 255, 255));
        TiepNhan.setName("pnTiepNhan"); // NOI18N

        jXTitledPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel5.setForeground(new java.awt.Color(255, 255, 255));
        jXTitledPanel5.setTitle("Tiếp Nhận");

        jPanel12.setBackground(new java.awt.Color(255, 255, 255));
        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder("Tiếp nhận"));

        jLabel11.setText("Mã số:");

        jLabel12.setText("Họ và tên:");

        jLabel13.setText("Ngày sinh:");

        jLabel14.setText("Tuổi:");

        jLabel15.setText("Cân nặng:");

        txtPatientIdReception.setText("####");
        txtPatientIdReception.setEnabled(false);

        txtPatientAgeReception.setEnabled(false);

        jLabel16.setText("Giới tính:");

        jLabel17.setText("CMND:");

        jLabel18.setText("Địa chỉ:");

        jLabel19.setText("Điện thoại:");

        jLabel20.setText("Người thân:");

        cbbPatientSexReception.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Chưa cập nhật", "Nam", "Nữ" }));

        btnRegisterReception.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Save_16x16.png"))); // NOI18N
        btnRegisterReception.setLabel("Đăng ký");
        btnRegisterReception.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegisterReceptionActionPerformed(evt);
            }
        });

        datePickerDOB.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                datePickerDOBPropertyChange(evt);
            }
        });

        btnRefreshReception.setVisible(false);
        btnRefreshReception.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Open_16x16.png"))); // NOI18N
        btnRefreshReception.setText("Tiếp nhận mới");
        btnRefreshReception.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshReceptionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(jLabel11)
                        .addGap(4, 4, 4)
                        .addComponent(txtPatientIdReception, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(14, 14, 14)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtPatientNameReception, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGap(25, 25, 25)
                                .addComponent(jLabel18))
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGap(9, 9, 9)
                                .addComponent(jLabel19)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtPatientAddressReception)
                            .addComponent(txtPatientPhoneReception)))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbbPatientSexReception, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(datePickerDOB, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGap(41, 41, 41)
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txtPatientAgeReception, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(jLabel15)
                                .addGap(4, 4, 4)
                                .addComponent(txtPatientWeightReception, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGap(32, 32, 32)
                                .addComponent(jLabel17)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txtPatientIdCardReception, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jLabel20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtPatientRelativeReception))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnRefreshReception)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRegisterReception, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtPatientIdReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtPatientNameReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel12))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel11)))
                .addGap(6, 6, 6)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtPatientAgeReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel14))
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtPatientWeightReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel15))
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel13)
                        .addComponent(datePickerDOB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(6, 6, 6)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtPatientIdCardReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel17))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(cbbPatientSexReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(6, 6, 6)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel18))
                    .addComponent(txtPatientAddressReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(txtPatientPhoneReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(txtPatientRelativeReception, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(43, 43, 43)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRegisterReception, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnRefreshReception, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(72, 72, 72))
        );

        jPanel13.setBackground(new java.awt.Color(255, 255, 255));
        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách bệnh nhân"));

        jLabel21.setText("Ngày khám:");

        datePickerTreatment.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                datePickerTreatmentActionPerformed(evt);
            }
        });

        tblPatients.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblPatients.setEditable(false);
        tblPatients.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblPatientsMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblPatients);

        btnReTreatmentReception.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Organizer_16x16.png"))); // NOI18N
        btnReTreatmentReception.setText("Đăng ký tái khám");
        btnReTreatmentReception.setEnabled(false);
        btnReTreatmentReception.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReTreatmentReceptionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel21)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(datePickerTreatment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnReTreatmentReception)))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(datePickerTreatment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnReTreatmentReception, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23))
        );

        jPanel9.setBackground(new java.awt.Color(255, 255, 255));
        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Tìm kiếm bệnh nhân"));

        jLabel22.setText("Mã số:");

        jLabel23.setText("Họ tên:");

        jLabel24.setText("Năm sinh:");

        jLabel25.setText("Giới tính:");

        jLabel26.setText("Số CMND:");

        btnSearchPa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Find_16x16.png"))); // NOI18N
        btnSearchPa.setText("Tìm kiếm");
        btnSearchPa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchPaActionPerformed(evt);
            }
        });

        cbbSearchPaSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-------", "Chưa cập nhật", "Nam", "Nữ" }));

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addComponent(jLabel22))
                            .addComponent(jLabel24))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtSearchPaYear, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                            .addComponent(txtSearchPaId))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel23, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel25, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtSearchPaName, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbbSearchPaSex, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel26)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtSearchPaIdCard))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnSearchPa, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(jLabel23)
                    .addComponent(txtSearchPaId)
                    .addComponent(txtSearchPaName, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(jLabel25)
                    .addComponent(txtSearchPaYear, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbSearchPaSex, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(txtSearchPaIdCard, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnSearchPa, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout TiepNhanLayout = new javax.swing.GroupLayout(TiepNhan);
        TiepNhan.setLayout(TiepNhanLayout);
        TiepNhanLayout.setHorizontalGroup(
            TiepNhanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTitledPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(TiepNhanLayout.createSequentialGroup()
                .addGroup(TiepNhanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(1, 1, 1))
        );
        TiepNhanLayout.setVerticalGroup(
            TiepNhanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TiepNhanLayout.createSequentialGroup()
                .addComponent(jXTitledPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(TiepNhanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(TiepNhanLayout.createSequentialGroup()
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(3, 3, 3))
        );

        tabParent.addTab("Tiếp nhận", new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png")), TiepNhan); // NOI18N
        TiepNhan.getAccessibleContext().setAccessibleName("");

        HoSoBenhAn.setBackground(new java.awt.Color(255, 255, 255));
        HoSoBenhAn.setToolTipText("Tiếp nhận bệnh nhân");

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));
        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Tìm kiếm"));

        jLabel34.setText("Họ tên:");

        jLabel35.setText("Năm sinh:");

        jLabel36.setText("Giới tính:");

        jLabel37.setText("Số CMND:");

        jLabel38.setText("Ngày khám:");

        cbbTreatmentSearchPaSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-------", "Chưa cập nhật", "Nam", "Nữ" }));

        btnTreatmentSearchPa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Find_16x16.png"))); // NOI18N
        btnTreatmentSearchPa.setText("Tìm kiếm");
        btnTreatmentSearchPa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTreatmentSearchPaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(txtTreatmentSearchPaYear, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel36))
                    .addComponent(txtTreatmentSearchPaName, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel35)
                        .addGap(194, 194, 194)
                        .addComponent(cbbTreatmentSearchPaSex, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel38)
                            .addComponent(jLabel37))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(dpTreatmentSearchPaDOT, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(131, 131, 131))
                            .addComponent(txtTreatmentSearchPaIdCard, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE))))
                .addGap(10, 10, 10))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnTreatmentSearchPa, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel34)
                    .addComponent(txtTreatmentSearchPaName, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel35)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel36)
                        .addComponent(txtTreatmentSearchPaYear, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cbbTreatmentSearchPaSex, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel37)
                    .addComponent(txtTreatmentSearchPaIdCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel38)
                    .addComponent(dpTreatmentSearchPaDOT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnTreatmentSearchPa, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 18, Short.MAX_VALUE))
        );

        jPanel8.setBackground(new java.awt.Color(255, 255, 255));
        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin khám bệnh"));

        jLabel40.setText("Mã số:");

        jLabel41.setText("Họ tên:");

        jLabel42.setText("Giới tính:");

        jLabel43.setText("Ngày sinh:");

        jLabel44.setText("Địa chỉ:");

        jLabel45.setText("Điện thoại:");

        jLabel46.setText("Người thân:");

        txtTreatmentId.setEnabled(false);
        txtTreatmentId.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTreatmentIdActionPerformed(evt);
            }
        });

        txtTreatmentPaName.setEnabled(false);

        cbbTreatmentPaSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Chưa cập nhật", "Nam", "Nữ" }));
        cbbTreatmentPaSex.setEnabled(false);

        txtTreatmentPaDOB.setEnabled(false);

        txtTreatmentPaAddress.setEnabled(false);

        txtTreatmentPaPhone.setEnabled(false);

        txtTreatmentPaRelative.setEnabled(false);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Chuẩn đoán - điều trị"));

        jLabel47.setText("Triệu chứng:");

        jLabel48.setText("Chẩn đoán:");

        jLabel49.setText("Lời dặn:");

        cbbTreatmentDiagnosis.setEditor(null);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel49)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel47)
                        .addComponent(jLabel48)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtTreatmentSymptom, javax.swing.GroupLayout.DEFAULT_SIZE, 642, Short.MAX_VALUE)
                    .addComponent(txtTreatmentAdvice)
                    .addComponent(cbbTreatmentDiagnosis, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel47)
                    .addComponent(txtTreatmentSymptom, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel48)
                    .addComponent(cbbTreatmentDiagnosis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel49)
                    .addComponent(txtTreatmentAdvice, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jLabel50.setText("Ngày hẹn:");

        jLabel51.setText("Ngày thuốc:");

        jLabel52.setText("Toa thuốc mẫu:");

        cbbTreatmentPrescription.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbTreatmentPrescriptionItemStateChanged(evt);
            }
        });

        tblTreatmentPrescription.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Tên thuốc", "Đơn vị", "Sáng", "Trưa", "Chiều", "Tối", "Số lượng", "Cách dùng", "Trạng thái"
            }
        ));
        tblTreatmentPrescription.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblTreatmentPrescriptionMouseClicked(evt);
            }
        });
        tblTreatmentPrescription.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tblTreatmentPrescriptionKeyReleased(evt);
            }
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblTreatmentPrescriptionKeyPressed(evt);
            }
        });
        jScrollPane4.setViewportView(tblTreatmentPrescription);

        btnTreatmentSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Save_16x16.png"))); // NOI18N
        btnTreatmentSave.setText("Lưu");
        btnTreatmentSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTreatmentSaveActionPerformed(evt);
            }
        });

        btnTreatmentPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/print-icon.png"))); // NOI18N
        btnTreatmentPrint.setText("In toa");

        cbbTreatmentDayOfUsingMed.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        jLabel27.setText("Tiền khám:");

        txtTreatmentCost.setText("0 VND");

        txtTreatmentMedCost.setText("0 VND");

        btnTreatmentMedCost.setText("Tiền thuốc");
        btnTreatmentMedCost.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTreatmentMedCostActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGap(44, 44, 44)
                                .addComponent(jLabel40)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtTreatmentId, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(24, 24, 24)
                                .addComponent(jLabel41)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtTreatmentPaName))
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGap(80, 80, 80)
                                .addComponent(txtTreatmentPaAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGap(8, 8, 8)
                                .addComponent(jLabel42)
                                .addGap(8, 8, 8)
                                .addComponent(cbbTreatmentPaSex, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                                .addComponent(jLabel43)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtTreatmentPaDOB, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                                .addComponent(jLabel45)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtTreatmentPaPhone))))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel46)
                            .addComponent(jLabel44))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtTreatmentPaRelative, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(jLabel50)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dpTreatmentDOReT, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel51)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbbTreatmentDayOfUsingMed, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel52)
                        .addGap(18, 18, 18)
                        .addComponent(cbbTreatmentPrescription, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10))
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane4)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel27)
                        .addGap(18, 18, 18)
                        .addComponent(txtTreatmentCost)
                        .addGap(104, 104, 104)
                        .addComponent(btnTreatmentMedCost, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(txtTreatmentMedCost)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnTreatmentSave, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnTreatmentPrint))))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel40)
                        .addComponent(txtTreatmentId, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel41)
                        .addComponent(txtTreatmentPaName, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cbbTreatmentPaSex, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel43)
                        .addComponent(txtTreatmentPaDOB, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel42, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel44)
                    .addComponent(txtTreatmentPaAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel45)
                    .addComponent(txtTreatmentPaPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel46)
                    .addComponent(txtTreatmentPaRelative, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel50)
                    .addComponent(dpTreatmentDOReT, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel51)
                    .addComponent(jLabel52)
                    .addComponent(cbbTreatmentPrescription, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbTreatmentDayOfUsingMed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnTreatmentSave)
                        .addComponent(btnTreatmentPrint, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnTreatmentMedCost)
                        .addComponent(txtTreatmentMedCost)
                        .addComponent(txtTreatmentCost)
                        .addComponent(jLabel27)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jXTitledPanel6.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel6.setTitle("Hồ sơ bệnh án");

        jPanel10.setBackground(new java.awt.Color(255, 255, 255));
        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách bệnh nhân"));

        jLabel39.setText("Tình trạng:");

        cbbTreatmentStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "------", "Chờ khám", "Đang khám", "Đã khám" }));
        cbbTreatmentStatus.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbTreatmentStatusItemStateChanged(evt);
            }
        });

        tblTreatmentPatients.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblTreatmentPatients.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblTreatmentPatientsMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tblTreatmentPatients);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jLabel39)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbbTreatmentStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel39)
                    .addComponent(cbbTreatmentStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout HoSoBenhAnLayout = new javax.swing.GroupLayout(HoSoBenhAn);
        HoSoBenhAn.setLayout(HoSoBenhAnLayout);
        HoSoBenhAnLayout.setHorizontalGroup(
            HoSoBenhAnLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(HoSoBenhAnLayout.createSequentialGroup()
                .addGroup(HoSoBenhAnLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jXTitledPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        HoSoBenhAnLayout.setVerticalGroup(
            HoSoBenhAnLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(HoSoBenhAnLayout.createSequentialGroup()
                .addComponent(jXTitledPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(HoSoBenhAnLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(HoSoBenhAnLayout.createSequentialGroup()
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(HoSoBenhAnLayout.createSequentialGroup()
                        .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(2, 2, 2)))
                .addContainerGap())
        );

        tabParent.addTab("Hồ sơ bệnh án", new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png")), HoSoBenhAn); // NOI18N

        KhaiBaoVatTu.setBackground(new java.awt.Color(255, 255, 255));

        jXTitledPanel8.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel8.setTitle("Khai báo thuốc - vật tư");

        jPanel17.setBackground(new java.awt.Color(255, 255, 255));
        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder("Tìm kiếm thuốc - vật tư"));

        jLabel9.setText("Mã số:");

        jLabel28.setText("Tên thuốc:");

        jLabel30.setText("Hàm lượng:");

        jLabel32.setText("Đơn vị:");

        jLabel57.setText("Nhóm thuốc:");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Find_16x16.png"))); // NOI18N
        jButton6.setText("Tìm kiếm");

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel32)
                            .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabel28))
                                .addComponent(jLabel30))
                            .addComponent(jLabel57))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField3)
                            .addComponent(jTextField4)
                            .addComponent(jTextField5)
                            .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel17Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton6)))
                .addContainerGap())
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addGap(3, 3, 3)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel30)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel32)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel57)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton6)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel18.setBackground(new java.awt.Color(255, 255, 255));
        jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách tìm kiếm"));

        jXTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Mã thuốc", "Tên thuốc", "Hàm lượng"
            }
        ));
        jScrollPane1.setViewportView(jXTable1);

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel19.setBackground(new java.awt.Color(255, 255, 255));
        jPanel19.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách thuốc"));

        jLabel58.setText("Mã số:");

        jLabel59.setText("Tên thuốc:");

        jLabel61.setText("Hàm lượng:");

        jLabel62.setText("Số lượng tồn:");

        jLabel83.setText("Đơn vị tính:");

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel84.setText("Nhóm thuốc:");

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel85.setText("Đường dùng:");

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jXTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane5.setViewportView(jXTable2);

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_SaveAs_16x16.png"))); // NOI18N
        jButton7.setText("Cập nhật");

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Save_16x16.png"))); // NOI18N
        jButton8.setText("Lưu");

        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png"))); // NOI18N
        jButton9.setText("Tạo mới");

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel83)
                            .addComponent(jLabel58))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextField6)
                            .addComponent(jComboBox3, 0, 114, Short.MAX_VALUE))
                        .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel19Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel59)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel19Layout.createSequentialGroup()
                                .addGap(4, 4, 4)
                                .addComponent(jLabel84)
                                .addGap(1, 1, 1)
                                .addComponent(jComboBox4, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel19Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jLabel61))
                            .addGroup(jPanel19Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel85)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel19Layout.createSequentialGroup()
                                .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel62)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField9))
                            .addComponent(jComboBox5, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(jScrollPane5)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel19Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton7)))
                .addContainerGap())
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel58)
                    .addComponent(jLabel59)
                    .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel61)
                    .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel62)
                    .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel83)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel84)
                    .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel85)
                    .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton7)
                    .addComponent(jButton8)
                    .addComponent(jButton9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 368, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout KhaiBaoVatTuLayout = new javax.swing.GroupLayout(KhaiBaoVatTu);
        KhaiBaoVatTu.setLayout(KhaiBaoVatTuLayout);
        KhaiBaoVatTuLayout.setHorizontalGroup(
            KhaiBaoVatTuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTitledPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, 1123, Short.MAX_VALUE)
            .addGroup(KhaiBaoVatTuLayout.createSequentialGroup()
                .addGroup(KhaiBaoVatTuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        KhaiBaoVatTuLayout.setVerticalGroup(
            KhaiBaoVatTuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(KhaiBaoVatTuLayout.createSequentialGroup()
                .addComponent(jXTitledPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(KhaiBaoVatTuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(KhaiBaoVatTuLayout.createSequentialGroup()
                        .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        tabParent.addTab("Khai báo thuốc - vật tư", new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png")), KhaiBaoVatTu); // NOI18N

        ChuanDoanBenh.setBackground(new java.awt.Color(255, 255, 255));

        jXTitledPanel14.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel14.setTitle("Chuẩn đoán bệnh");

        jPanel21.setBackground(new java.awt.Color(255, 255, 255));
        jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin chuẩn đoán"));

        jLabel60.setText("Tên CĐ:");

        btnDiagnosisSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Save_16x16.png"))); // NOI18N
        btnDiagnosisSave.setText("Lưu");
        btnDiagnosisSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDiagnosisSaveActionPerformed(evt);
            }
        });

        btnDiagnosisUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_SaveAs_16x16.png"))); // NOI18N
        btnDiagnosisUpdate.setText("Cập nhật");
        btnDiagnosisUpdate.setEnabled(false);
        btnDiagnosisUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDiagnosisUpdateActionPerformed(evt);
            }
        });

        jLabel114.setText("Mã số:");

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel21Layout.createSequentialGroup()
                        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel114)
                            .addComponent(jLabel60))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtDiagnosisName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jTextField20)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel21Layout.createSequentialGroup()
                        .addGap(0, 99, Short.MAX_VALUE)
                        .addComponent(btnDiagnosisSave, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDiagnosisUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel114)
                    .addComponent(jTextField20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel60)
                    .addComponent(txtDiagnosisName, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnDiagnosisSave)
                    .addComponent(btnDiagnosisUpdate))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel22.setBackground(new java.awt.Color(255, 255, 255));
        jPanel22.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách chuẩn đoán"));

        tblDiagnosis.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Tên chuẩn đoán"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblDiagnosis.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblDiagnosisMouseClicked(evt);
            }
        });
        jScrollPane8.setViewportView(tblDiagnosis);
        if (tblDiagnosis.getColumnModel().getColumnCount() > 0) {
            tblDiagnosis.getColumnModel().getColumn(0).setMaxWidth(200);
        }

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8)
                .addContainerGap())
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout ChuanDoanBenhLayout = new javax.swing.GroupLayout(ChuanDoanBenh);
        ChuanDoanBenh.setLayout(ChuanDoanBenhLayout);
        ChuanDoanBenhLayout.setHorizontalGroup(
            ChuanDoanBenhLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTitledPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, 1123, Short.MAX_VALUE)
            .addGroup(ChuanDoanBenhLayout.createSequentialGroup()
                .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(19, 19, 19))
        );
        ChuanDoanBenhLayout.setVerticalGroup(
            ChuanDoanBenhLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ChuanDoanBenhLayout.createSequentialGroup()
                .addComponent(jXTitledPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ChuanDoanBenhLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(3, 3, 3))
        );

        tabParent.addTab("Chuẩn đoán bệnh", ChuanDoanBenh);

        NhanVienBacSy.setBackground(new java.awt.Color(255, 255, 255));

        jXTitledPanel16.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel16.setTitle("Nhân viên - bác sỹ");

        jPanel25.setBackground(new java.awt.Color(255, 255, 255));
        jPanel25.setBorder(javax.swing.BorderFactory.createTitledBorder("Tìm kiếm nhân viên"));

        jLabel63.setText("Mã số:");

        jLabel64.setText("Họ tên:");

        jLabel65.setText("Năm sinh:");

        jLabel66.setText("Nhóm:");

        jLabel67.setText("Tình trạng:");

        cbbWorkerStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "------", "Đang làm", "Đã nghỉ làm" }));

        cbbWorkerGroup.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "------", "Bác sĩ", "Nhân viên nhà thuốc", "Y tá", "Quản lý" }));

        btnWorkerSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Find_16x16.png"))); // NOI18N
        btnWorkerSearch.setText("Tìm kiếm");
        btnWorkerSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWorkerSearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel25Layout = new javax.swing.GroupLayout(jPanel25);
        jPanel25.setLayout(jPanel25Layout);
        jPanel25Layout.setHorizontalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel25Layout.createSequentialGroup()
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel25Layout.createSequentialGroup()
                        .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel67)
                            .addComponent(jLabel63)
                            .addComponent(jLabel65)
                            .addComponent(jLabel64)
                            .addComponent(jLabel66))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtWorkerId, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtWorkerName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtWorkerYear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbbWorkerStatus, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbbWorkerGroup, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel25Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnWorkerSearch)))
                .addContainerGap())
        );
        jPanel25Layout.setVerticalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel25Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel63)
                    .addComponent(txtWorkerId, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel64)
                    .addComponent(txtWorkerName, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel65)
                    .addComponent(txtWorkerYear, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel66)
                    .addComponent(cbbWorkerGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel67)
                    .addComponent(cbbWorkerStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(btnWorkerSearch)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel26.setBackground(new java.awt.Color(255, 255, 255));
        jPanel26.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách tìm kiếm"));

        tblWorkerSearchResult.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Mã số", "Họ tên", "Năm sinh"
            }
        ));
        tblWorkerSearchResult.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblWorkerSearchResultMouseClicked(evt);
            }
        });
        jScrollPane10.setViewportView(tblWorkerSearchResult);

        javax.swing.GroupLayout jPanel26Layout = new javax.swing.GroupLayout(jPanel26);
        jPanel26.setLayout(jPanel26Layout);
        jPanel26Layout.setHorizontalGroup(
            jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel26Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel26Layout.setVerticalGroup(
            jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel26Layout.createSequentialGroup()
                .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel27.setBackground(new java.awt.Color(255, 255, 255));
        jPanel27.setBorder(javax.swing.BorderFactory.createTitledBorder("Quản lý nhân viên"));

        jLabel68.setText("Mã số:");

        jLabel69.setText("Họ tên:");

        jLabel70.setText("Giới tính:");

        jLabel71.setText("Ngày sinh:");

        txtWorkerMainId.setEnabled(false);

        cbbWorkerMainSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Chưa cập nhật", "Nam", "Nữ" }));

        jLabel72.setText("Địa chỉ:");

        jLabel73.setText("Điện thoại:");

        jLabel74.setText("Số CMND:");

        jLabel75.setText("Nhóm:");

        jLabel76.setText("Tên ĐN:");

        jLabel77.setText("Mật khẩu:");

        jLabel78.setText("Tình trạng:");

        cbbWorkerMainStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "------", "Đang làm", "Đã nghỉ làm" }));

        btnWorkerMainNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png"))); // NOI18N
        btnWorkerMainNew.setText("Nhân viên mới");
        btnWorkerMainNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWorkerMainNewActionPerformed(evt);
            }
        });

        btnWorkerMainUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_SaveAs_16x16.png"))); // NOI18N
        btnWorkerMainUpdate.setText("Cập nhật");
        btnWorkerMainUpdate.setEnabled(false);
        btnWorkerMainUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWorkerMainUpdateActionPerformed(evt);
            }
        });

        btnWorkerMainSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Save_16x16.png"))); // NOI18N
        btnWorkerMainSave.setText("Lưu");
        btnWorkerMainSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWorkerMainSaveActionPerformed(evt);
            }
        });

        jPanel32.setBackground(new java.awt.Color(255, 255, 255));
        jPanel32.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách nhân viên bác sỹ"));

        tblWorkerMain.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Mã số", "Họ tên", "Năm sinh", "Giới tính", "Địa chỉ", "Điện thoại", "Số CMND", "Nhóm ", "Tên đăng nhập", "Tình trạng"
            }
        ));
        tblWorkerMain.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblWorkerMainMouseClicked(evt);
            }
        });
        jScrollPane11.setViewportView(tblWorkerMain);

        javax.swing.GroupLayout jPanel32Layout = new javax.swing.GroupLayout(jPanel32);
        jPanel32.setLayout(jPanel32Layout);
        jPanel32Layout.setHorizontalGroup(
            jPanel32Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel32Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel32Layout.setVerticalGroup(
            jPanel32Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel32Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
                .addContainerGap())
        );

        dpWorkerMainDOB.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                dpWorkerMainDOBPropertyChange(evt);
            }
        });

        cbbWorkerMainGroup.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "------", "Bác sĩ", "Nhân viên nhà thuốc", "Y tá", "Quản lý" }));

        javax.swing.GroupLayout jPanel27Layout = new javax.swing.GroupLayout(jPanel27);
        jPanel27.setLayout(jPanel27Layout);
        jPanel27Layout.setHorizontalGroup(
            jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel27Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel27Layout.createSequentialGroup()
                        .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel78)
                            .addComponent(jLabel74)
                            .addComponent(jLabel72)
                            .addComponent(jLabel68))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel27Layout.createSequentialGroup()
                                .addComponent(txtWorkerMainId, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel69)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtWorkerMainName, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(15, 15, 15)
                                .addComponent(jLabel70)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbbWorkerMainSex, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel71)
                                .addGap(14, 14, 14)
                                .addComponent(dpWorkerMainDOB, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel27Layout.createSequentialGroup()
                                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(jPanel27Layout.createSequentialGroup()
                                            .addComponent(txtWorkerMainIdCard, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(jLabel75)
                                            .addGap(18, 18, 18)
                                            .addComponent(cbbWorkerMainGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(txtWorkerMainAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 365, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(cbbWorkerMainStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel27Layout.createSequentialGroup()
                                        .addComponent(jLabel73)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtWorkerMainPhone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGroup(jPanel27Layout.createSequentialGroup()
                                        .addGap(14, 14, 14)
                                        .addComponent(jLabel76)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtWorkerMainUser, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel77)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtWorkerMainPass, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                            .addGroup(jPanel27Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(btnWorkerMainNew)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnWorkerMainUpdate)
                                .addGap(7, 7, 7)
                                .addComponent(btnWorkerMainSave, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jPanel32, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(10, 10, 10))
        );
        jPanel27Layout.setVerticalGroup(
            jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel27Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtWorkerMainId, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel68)
                    .addComponent(jLabel69)
                    .addComponent(txtWorkerMainName, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel70)
                    .addComponent(cbbWorkerMainSex, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel71)
                    .addComponent(dpWorkerMainDOB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel72)
                    .addComponent(txtWorkerMainAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel73)
                    .addComponent(txtWorkerMainPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel74)
                    .addComponent(txtWorkerMainIdCard, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel75)
                    .addComponent(jLabel76)
                    .addComponent(txtWorkerMainUser, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel77)
                    .addComponent(txtWorkerMainPass, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbWorkerMainGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel78)
                    .addComponent(cbbWorkerMainStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnWorkerMainSave)
                    .addComponent(btnWorkerMainUpdate)
                    .addComponent(btnWorkerMainNew))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel32, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout NhanVienBacSyLayout = new javax.swing.GroupLayout(NhanVienBacSy);
        NhanVienBacSy.setLayout(NhanVienBacSyLayout);
        NhanVienBacSyLayout.setHorizontalGroup(
            NhanVienBacSyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTitledPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, 1123, Short.MAX_VALUE)
            .addGroup(NhanVienBacSyLayout.createSequentialGroup()
                .addGroup(NhanVienBacSyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18))
        );
        NhanVienBacSyLayout.setVerticalGroup(
            NhanVienBacSyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(NhanVienBacSyLayout.createSequentialGroup()
                .addComponent(jXTitledPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(NhanVienBacSyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(NhanVienBacSyLayout.createSequentialGroup()
                        .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        tabParent.addTab("Nhân viên - bác sỹ", NhanVienBacSy);

        KhaiBaoToaMau.setBackground(new java.awt.Color(255, 255, 255));

        jXTitledPanel17.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel17.setTitle("Khai báo toa mẫu");

        jPanel28.setBackground(new java.awt.Color(255, 255, 255));
        jPanel28.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách toa mẫu"));

        jXTable10.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Mã số", "Tên toa", "Mô tả"
            }
        ));
        jScrollPane12.setViewportView(jXTable10);

        javax.swing.GroupLayout jPanel28Layout = new javax.swing.GroupLayout(jPanel28);
        jPanel28.setLayout(jPanel28Layout);
        jPanel28Layout.setHorizontalGroup(
            jPanel28Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel28Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel28Layout.setVerticalGroup(
            jPanel28Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel28Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel29.setBackground(new java.awt.Color(255, 255, 255));
        jPanel29.setBorder(javax.swing.BorderFactory.createTitledBorder("Khai báo toa mẫu"));

        jLabel79.setText("Mã số:");

        jLabel80.setText("Tên toa mẫu:");

        jLabel81.setText("Mô tả:");

        jLabel82.setText("Danh sách thuốc");

        jXTable11.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Tên thuốc", "Hàm lượng", "Sáng", "Trưa", "Chiều", "Tối", "Đơn vị", "Cách dùng", "Số lượng"
            }
        ));
        jScrollPane13.setViewportView(jXTable11);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Trash_16x16.png"))); // NOI18N
        jButton2.setText("Xóa toa mẫu");

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_SaveAs_16x16.png"))); // NOI18N
        jButton3.setText("Cập nhật");

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Save_16x16.png"))); // NOI18N
        jButton4.setText("Lưu toa mẫu");

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png"))); // NOI18N
        jButton5.setText("Toa mẫu mới");

        javax.swing.GroupLayout jPanel29Layout = new javax.swing.GroupLayout(jPanel29);
        jPanel29.setLayout(jPanel29Layout);
        jPanel29Layout.setHorizontalGroup(
            jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel29Layout.createSequentialGroup()
                .addGroup(jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel29Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel81)
                            .addComponent(jLabel79))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel29Layout.createSequentialGroup()
                                .addComponent(jXTextField23, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel80)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jXTextField24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jXTextField25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel29Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 751, Short.MAX_VALUE))
                    .addGroup(jPanel29Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel82)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel29Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel29Layout.setVerticalGroup(
            jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel29Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel79)
                    .addComponent(jXTextField23, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel80)
                    .addComponent(jXTextField24, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel81)
                    .addComponent(jXTextField25, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(38, 38, 38)
                .addComponent(jLabel82)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton4)
                    .addComponent(jButton5))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout KhaiBaoToaMauLayout = new javax.swing.GroupLayout(KhaiBaoToaMau);
        KhaiBaoToaMau.setLayout(KhaiBaoToaMauLayout);
        KhaiBaoToaMauLayout.setHorizontalGroup(
            KhaiBaoToaMauLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTitledPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, 1123, Short.MAX_VALUE)
            .addGroup(KhaiBaoToaMauLayout.createSequentialGroup()
                .addComponent(jPanel28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel29, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        KhaiBaoToaMauLayout.setVerticalGroup(
            KhaiBaoToaMauLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(KhaiBaoToaMauLayout.createSequentialGroup()
                .addComponent(jXTitledPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(KhaiBaoToaMauLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel29, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        tabParent.addTab("Khai báo toa mẫu", KhaiBaoToaMau);

        BaoCaoDoanhThu.setBackground(new java.awt.Color(255, 255, 255));
        BaoCaoDoanhThu.setName(""); // NOI18N

        jXTitledPanel9.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel9.setTitle("Báo cáo doanh thu");

        jPanel34.setBackground(new java.awt.Color(255, 255, 255));
        jPanel34.setBorder(javax.swing.BorderFactory.createTitledBorder("Báo cáo"));

        jXTable6.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Ngày", "Số bệnh nhân", "Số tiền"
            }
        ));
        jScrollPane15.setViewportView(jXTable6);

        javax.swing.GroupLayout jPanel34Layout = new javax.swing.GroupLayout(jPanel34);
        jPanel34.setLayout(jPanel34Layout);
        jPanel34Layout.setHorizontalGroup(
            jPanel34Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel34Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane15)
                .addContainerGap())
        );
        jPanel34Layout.setVerticalGroup(
            jPanel34Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel34Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane15, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jLabel112.setText("Từ ngày:");

        jLabel113.setText("Đến ngày:");

        jButton18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Content_16x16.png"))); // NOI18N
        jButton18.setText("Báo cáo");

        javax.swing.GroupLayout BaoCaoDoanhThuLayout = new javax.swing.GroupLayout(BaoCaoDoanhThu);
        BaoCaoDoanhThu.setLayout(BaoCaoDoanhThuLayout);
        BaoCaoDoanhThuLayout.setHorizontalGroup(
            BaoCaoDoanhThuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTitledPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, 1123, Short.MAX_VALUE)
            .addComponent(jPanel34, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(BaoCaoDoanhThuLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel112)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jXDatePicker2, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel113)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jXDatePicker3, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton18, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        BaoCaoDoanhThuLayout.setVerticalGroup(
            BaoCaoDoanhThuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(BaoCaoDoanhThuLayout.createSequentialGroup()
                .addComponent(jXTitledPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(BaoCaoDoanhThuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel112)
                    .addComponent(jXDatePicker2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel113)
                    .addComponent(jXDatePicker3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        tabParent.addTab("Báo cáo doanh thu", new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png")), BaoCaoDoanhThu); // NOI18N

        PhanQuyen.setBackground(new java.awt.Color(255, 255, 255));

        jXTitledPanel10.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jXTitledPanel10.setTitle("Phân quyền sử dụng");

        jPanel30.setBackground(new java.awt.Color(255, 255, 255));
        jPanel30.setBorder(javax.swing.BorderFactory.createTitledBorder("Quản lý nhóm"));

        jLabel86.setText("Mã nhóm:");

        jLabel87.setText("Tên nhóm:");

        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Trash_16x16.png"))); // NOI18N
        jButton10.setText("Xóa");

        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_SaveAs_16x16.png"))); // NOI18N
        jButton11.setText("Cập nhật");

        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Save_16x16.png"))); // NOI18N
        jButton12.setText("Lưu");

        jLabel88.setText("Danh sách nhóm");

        jXTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Mã nhóm", "Tên nhóm"
            }
        ));
        jScrollPane6.setViewportView(jXTable3);

        javax.swing.GroupLayout jPanel30Layout = new javax.swing.GroupLayout(jPanel30);
        jPanel30.setLayout(jPanel30Layout);
        jPanel30Layout.setHorizontalGroup(
            jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel30Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel30Layout.createSequentialGroup()
                        .addGroup(jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel87)
                            .addComponent(jLabel86))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField11, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextField10, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addGroup(jPanel30Layout.createSequentialGroup()
                        .addComponent(jLabel88)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane6)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel30Layout.createSequentialGroup()
                        .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel30Layout.setVerticalGroup(
            jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel30Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel86)
                    .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel87)
                    .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel30Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton10)
                    .addComponent(jButton11)
                    .addComponent(jButton12))
                .addGap(18, 18, 18)
                .addComponent(jLabel88)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel31.setBackground(new java.awt.Color(255, 255, 255));
        jPanel31.setBorder(javax.swing.BorderFactory.createTitledBorder("Phân quyền"));

        jLabel89.setText("Chọn nhóm:");

        jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel90.setText("Chức năng:");

        jScrollPane9.setViewportView(jXTree1);

        javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
        jPanel20.setLayout(jPanel20Layout);
        jPanel20Layout.setHorizontalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE)
        );
        jPanel20Layout.setVerticalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
        );

        jButton13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_SaveAs_16x16.png"))); // NOI18N
        jButton13.setText("Cập nhật");

        jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Exit_16x16.png"))); // NOI18N
        jButton14.setText("Bỏ chọn tất cả");

        javax.swing.GroupLayout jPanel31Layout = new javax.swing.GroupLayout(jPanel31);
        jPanel31.setLayout(jPanel31Layout);
        jPanel31Layout.setHorizontalGroup(
            jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel31Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel31Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton13))
                    .addGroup(jPanel31Layout.createSequentialGroup()
                        .addGroup(jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel90)
                            .addComponent(jLabel89))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGap(16, 16, 16))
        );
        jPanel31Layout.setVerticalGroup(
            jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel31Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel89)
                    .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel90)
                    .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel31Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton14)
                    .addComponent(jButton13))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout PhanQuyenLayout = new javax.swing.GroupLayout(PhanQuyen);
        PhanQuyen.setLayout(PhanQuyenLayout);
        PhanQuyenLayout.setHorizontalGroup(
            PhanQuyenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTitledPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(PhanQuyenLayout.createSequentialGroup()
                .addComponent(jPanel30, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel31, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        PhanQuyenLayout.setVerticalGroup(
            PhanQuyenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PhanQuyenLayout.createSequentialGroup()
                .addComponent(jXTitledPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addGroup(PhanQuyenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel30, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel31, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        tabParent.addTab("Phân quyền sử dụng", new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_New_16x16.png")), PhanQuyen); // NOI18N

        ThanhToan.setBackground(new java.awt.Color(255, 255, 255));

        jPanel23.setBackground(new java.awt.Color(255, 255, 255));
        jPanel23.setBorder(javax.swing.BorderFactory.createTitledBorder("Tìm kiếm bệnh nhân"));

        jLabel91.setText("Mã số KB:");

        jLabel92.setText("Họ tên:");

        jLabel93.setText("Năm sinh:");

        jLabel94.setText("Giới tính:");

        jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel95.setText("Số CMND:");

        jLabel96.setText("Ngày khám:");

        jLabel97.setText("Tình trạng:");

        jComboBox8.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButton15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Ribbon_Find_16x16.png"))); // NOI18N
        jButton15.setText("Tìm kiếm");

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel23Layout.createSequentialGroup()
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel97)
                            .addComponent(jLabel96))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jXDatePicker1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboBox8, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel91)
                                    .addComponent(jLabel92))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField2)
                                    .addComponent(jTextField12)))
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addComponent(jLabel93)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel94)
                                .addGap(10, 10, 10)
                                .addComponent(jComboBox7, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addComponent(jLabel95)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField14))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel23Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jButton15)))))
                .addContainerGap())
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel91)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel92)
                    .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel93)
                    .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel94)
                    .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel95)
                    .addComponent(jTextField14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel96)
                    .addComponent(jXDatePicker1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel97))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton15)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel24.setBackground(new java.awt.Color(255, 255, 255));
        jPanel24.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách"));

        jLabel98.setText("Thanh toán:");

        jComboBox9.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jXTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane7.setViewportView(jXTable4);

        javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
        jPanel24.setLayout(jPanel24Layout);
        jPanel24Layout.setHorizontalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel24Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
                    .addGroup(jPanel24Layout.createSequentialGroup()
                        .addComponent(jLabel98)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox9, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel24Layout.setVerticalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel24Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel98)
                    .addComponent(jComboBox9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel33.setBackground(new java.awt.Color(255, 255, 255));
        jPanel33.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin hóa đơn"));

        jLabel99.setText("Mã số:");

        jLabel100.setText("Họ tên:");

        jLabel101.setText("Giới tính:");

        jComboBox10.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel102.setText("Ngày sinh:");

        jLabel103.setText("Địa chỉ:");

        jLabel104.setText("CMND:");

        jLabel105.setText("Chuẩn đoán:");

        jXTable5.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane14.setViewportView(jXTable5);

        jCheckBox1.setSelected(true);
        jCheckBox1.setText("Sử dụng thuốc:");

        jLabel106.setText("Tiền khám:");

        jLabel107.setText("Tiền thuốc:");

        jLabel108.setText("Tổng tiền:");

        jLabel109.setText("0");

        jLabel110.setText("0");

        jLabel111.setText("0");

        jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Tasks_16x16.png"))); // NOI18N
        jButton16.setText("Thanh toán");

        jButton17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/print-icon.png"))); // NOI18N
        jButton17.setText("In hóa đơn");

        javax.swing.GroupLayout jPanel33Layout = new javax.swing.GroupLayout(jPanel33);
        jPanel33.setLayout(jPanel33Layout);
        jPanel33Layout.setHorizontalGroup(
            jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel33Layout.createSequentialGroup()
                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel33Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel33Layout.createSequentialGroup()
                                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel103)
                                    .addComponent(jLabel99))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel33Layout.createSequentialGroup()
                                        .addComponent(jTextField15, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel100)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextField16, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel101)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jComboBox10, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jTextField18))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel102)
                                    .addComponent(jLabel104))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField17)
                                    .addComponent(jTextField19)))
                            .addComponent(jScrollPane14)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel33Layout.createSequentialGroup()
                                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel33Layout.createSequentialGroup()
                                        .addComponent(jCheckBox1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel106))
                                    .addGroup(jPanel33Layout.createSequentialGroup()
                                        .addGap(0, 0, Short.MAX_VALUE)
                                        .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel107)
                                            .addComponent(jLabel108))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel111, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                                    .addComponent(jLabel110, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel109, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel33Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel105)
                                    .addGroup(jPanel33Layout.createSequentialGroup()
                                        .addGap(496, 496, 496)
                                        .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(114, 114, 114))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel33Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton17)))
                .addContainerGap())
        );
        jPanel33Layout.setVerticalGroup(
            jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel33Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel99)
                    .addComponent(jTextField15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel100)
                    .addComponent(jTextField16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel101)
                    .addComponent(jComboBox10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel102)
                    .addComponent(jTextField17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel103)
                    .addComponent(jTextField18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel104)
                    .addComponent(jTextField19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37)
                .addComponent(jLabel105)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane14, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBox1)
                    .addComponent(jLabel106)
                    .addComponent(jLabel109))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel107)
                    .addComponent(jLabel110))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel108)
                    .addComponent(jLabel111))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 114, Short.MAX_VALUE)
                .addGroup(jPanel33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton16))
                .addGap(19, 19, 19))
        );

        javax.swing.GroupLayout ThanhToanLayout = new javax.swing.GroupLayout(ThanhToan);
        ThanhToan.setLayout(ThanhToanLayout);
        ThanhToanLayout.setHorizontalGroup(
            ThanhToanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ThanhToanLayout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(ThanhToanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        ThanhToanLayout.setVerticalGroup(
            ThanhToanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ThanhToanLayout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(ThanhToanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(ThanhToanLayout.createSequentialGroup()
                        .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        tabParent.addTab("Thanh toán", ThanhToan);

        NhapKho.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout NhapKhoLayout = new javax.swing.GroupLayout(NhapKho);
        NhapKho.setLayout(NhapKhoLayout);
        NhapKhoLayout.setHorizontalGroup(
            NhapKhoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1123, Short.MAX_VALUE)
        );
        NhapKhoLayout.setVerticalGroup(
            NhapKhoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 531, Short.MAX_VALUE)
        );

        tabParent.addTab("Nhập kho", NhapKho);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabMenuBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(tabParent, javax.swing.GroupLayout.DEFAULT_SIZE, 1128, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(TabMenuBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(tabParent, javax.swing.GroupLayout.PREFERRED_SIZE, 561, Short.MAX_VALUE))
        );

        TabMenuBar.getAccessibleContext().setAccessibleName("Trợ giúp");

        setSize(new java.awt.Dimension(1144, 739));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void initMyEvents() {
        txtSearchPaId.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                checkSearchDataInput(txtSearchPaId);
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                checkSearchDataInput(txtSearchPaId);
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
        txtSearchPaIdCard.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                checkSearchDataInput(txtSearchPaIdCard);
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                checkSearchDataInput(txtSearchPaIdCard);
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
        txtTreatmentSearchPaIdCard.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                checkSearchDataInput(txtTreatmentSearchPaIdCard);
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                checkSearchDataInput(txtTreatmentSearchPaIdCard);
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
        txtWorkerId.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                checkSearchDataInput(txtWorkerId);
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                checkSearchDataInput(txtWorkerId);
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
    }

    private void checkSearchDataInput(JTextField text) {
        if (text.getText().length() <= 0) {
            allowSearchMore(text, true);
        } else {
            allowSearchMore(text, false);
        }
    }

    private void allowSearchMore(JTextField input, boolean allow) {
        if (input.equals(txtSearchPaId)) {
            txtSearchPaName.setEnabled(allow);
            txtSearchPaYear.setEnabled(allow);
            cbbSearchPaSex.setEnabled(allow);
            txtSearchPaIdCard.setEnabled(allow);
            return;
        }
        if (input.equals(txtSearchPaIdCard)) {
            txtSearchPaName.setEnabled(allow);
            txtSearchPaYear.setEnabled(allow);
            cbbSearchPaSex.setEnabled(allow);
            txtSearchPaId.setEnabled(allow);
            return;
        }
        if (input.equals(txtTreatmentSearchPaIdCard)) {
            txtTreatmentSearchPaYear.setEnabled(allow);
            txtTreatmentSearchPaName.setEnabled(allow);
            cbbTreatmentSearchPaSex.setEnabled(allow);
            dpTreatmentSearchPaDOT.setEnabled(allow);
            return;
        }
        if (input.equals(txtWorkerId)) {
            txtWorkerName.setEnabled(allow);
            txtWorkerYear.setEnabled(allow);
            cbbWorkerGroup.setEnabled(allow);
            cbbWorkerStatus.setEnabled(allow);
            return;
        }
    }

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        //Update date picker
        datePickerTreatment.setDate(new Date());
        try {
            Calendar cal = Calendar.getInstance();
            CMDateTime cmDate = myQueryBL.getCMDateTime(cal.get(Calendar.YEAR),
                    cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));

            String[] colNames = new String[]{"Mã bệnh nhân", "Họ tên", "Năm sinh",
                "CMND", "Tình trạng", "Thanh toán"};
            Hashtable<Integer, Integer> options = new Hashtable<>();
            options.put(4, TREATMENT_STATUS);
            options.put(5, PAY_STATUS);
            fillDataOnTableFromArray(tblPatients, getPatientByDateOfTreatment(cmDate),
                    colNames, options, true);
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_formWindowOpened

    private void tabParentMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabParentMouseClicked
        int index = tabParent.getSelectedIndex();
        switch (index) {
            case 0:// Tiep nhan
                break;
            case 1:// Ho so benh an
                if (dpTreatmentSearchPaDOT.getDate() != null) {
                    return;
                }
                dpTreatmentSearchPaDOT.setDate(new Date());
                try {
                    //Load toa mau
                    Prescription[] pre = prescriptionBL.getAllPrescription();
                    if (pre == null || pre.length <= 0) {
                        return;
                    }
                    String[] preName = new String[pre.length + 1];
                    preName[0] = "-----";
                    for (int i = 0; i < pre.length; i++) {
                        preName[i + 1] = pre[i].getPrescriptionName();
                    }
                    ComboBoxModel e = new DefaultComboBoxModel(preName);
                    cbbTreatmentPrescription.setModel(e);

                    //Load chan đoan
                    String[] diag = treatmentBL.getAllDiagnosis();
                    if (diag == null || diag.length <= 0) {
                        return;
                    }
                    cbbTreatmentDiagnosis.setModel(new DefaultComboBoxModel(diag));

                    //Load tiền khám
                    int treCost = treatmentBL.getTreatmentCost();
                    if (treCost == -1) {
                        treCost = 0;
                    }
                    txtTreatmentCost.setText(treCost + "vnd");
                    
                    //load patient in day
                    cbbTreatmentStatus.setSelectedIndex(1);//cho kham

                } catch (GenericUserException ex) {
                    Logger.getLogger(MainForm.class
                            .getName()).log(Level.SEVERE, null, ex);
                }
                break;
            case 2:
                break;
            case 3:
                try {
                    //Diagnosis
                    String[] data = treatmentBL.getAllDiagnosis();
                    if (data == null || data.length <= 0) {
                        return;
                    }
                    String[] col = new String[]{"Tên chẩn đoán"};
                    fillDataOnTableFromArray(tblDiagnosis, data, col, null, false);
                } catch (GenericUserException ex) {
                    Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                }
                break;
            case 4:
                try {
                    //
                    String query = "SELECT workerid "
                            + "      ,[fullname]\n"
                            + "      ,[idcard]\n"
                            + "      ,[sex]\n"
                            + "      ,[dateofbirth]\n"
                            + "      ,[address]\n"
                            + "      ,[phonenumber]\n"
                            + "      ,[positionid]\n"
                            + "      ,[username]\n"
                            + "      ,[status]\n"
                            + "  FROM WORKER";
                    String[] data = myQueryBL.doQuery(query);
                    if (data == null || data.length <= 0) {
                        return;
                    }
                    String[] col = new String[]{"Mã nhân viên", "Họ tên", "CMND",
                        "Giới tính", "Năm sinh", "Địa chỉ", "Điện thoại", "Nhóm", "Tên đăng nhập", "Tình trạng"};
                    Hashtable<Integer, Integer> options = new Hashtable<>();
                    options.put(3, SEX);
                    options.put(7, WORKER_GROUP);
                    options.put(9, WORKER_STATUS);
                    fillDataOnTableFromArray(tblWorkerMain, data, col, options, true);
                } catch (GenericUserException ex) {
                    Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                }
                break;

        }
    }//GEN-LAST:event_tabParentMouseClicked

    private void tblTreatmentPatientsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblTreatmentPatientsMouseClicked
        int rowIndex = tblTreatmentPatients.getSelectedRow();
        if (rowIndex == -1) {
            return;
        }
        String id = tblTreatmentPatients.getValueAt(rowIndex, 1).toString();
        int paId = Integer.parseInt(id);
        try {
            if (paId != -1) {
                Patient patient = patientBL.getPatientById(paId);
                if (patient != null) {
                    String treId = tblTreatmentPatients.getValueAt(rowIndex, 0).toString();
                    txtTreatmentId.setText(treId);
                    txtTreatmentPaName.setText(patient.getFullName());
                    txtTreatmentPaDOB.setText(patient.getDateOfBirth().toShortDateString());
                    txtTreatmentPaAddress.setText(patient.getAddress());
                    txtTreatmentPaPhone.setText(patient.getPhoneNumber());
                    txtTreatmentPaRelative.setText(patient.getRelative());

                    Sex sex = patient.getSex();
                    int index = sex == Sex.Sex_NONE ? 0
                            : (Sex._Sex_MALE == 1 ? 1 : 2);
                    cbbTreatmentPaSex.setSelectedIndex(index);
                }
            }
            else// try to find on server
            {
//                Date date = cbb
//                String query = "select treatmentid from treatment where patientid="+paId+
//                        " and year(dateoftreatment) ="+
//                        " and month(dateoftreatment)="+
//                        " and day(dateoftreatment)="+
            }
        } catch (NumberFormatException ne) {
            System.err.println(ne.getMessage());
            JOptionPane.showMessageDialog(null, "Có lỗi trong quá trình truy xuất dữ liệu");

        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class
                    .getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(
                    null, "Lỗi truyền và nhận dữ liệu CORBA");
        }
    }//GEN-LAST:event_tblTreatmentPatientsMouseClicked

    private void cbbTreatmentStatusItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbTreatmentStatusItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            int index = cbbTreatmentStatus.getSelectedIndex();
            if (index != 0) {
                CMDateTime date = utils.Util.convertDateToCMDateTime(myQueryBL, new Date());
                String query;
                try {
                    query = "select treatmentid, PATIENT.patientid, fullname,"
                     + " treatmentstatusid from "
                     + " PATIENT inner join TREATMENT on PATIENT.patientid=TREATMENT.patientid "
                     + " where treatmentstatusid=" + index
                     + " and year(dateoftreatment)="+date.getYear()
                     + " and month(dateoftreatment)="+date.getMonth()
                     + " and day(dateoftreatment)="+date.getDay();
                    String[] colNames = new String[]{"Mã Khám","Mã bệnh nhân", "Họ tên", "Tình trạng"};
                Hashtable<Integer, Integer> options = new Hashtable<>();
                options.put(3, TREATMENT_STATUS);
                boolean isFound = searchAndFill(tblTreatmentPatients,
                        query.toString(), colNames, options);
                if (!isFound) {
                    fillDataOnTableFromArray(tblTreatmentPatients, null, colNames, options, true);
                }
                } catch (GenericUserException ex) {
                    Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                }
                
            }
        }
    }//GEN-LAST:event_cbbTreatmentStatusItemStateChanged

    private void btnTreatmentSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTreatmentSaveActionPerformed
        Date reDate = dpTreatmentDOReT.getDate();
        if (reDate == null) {
            JOptionPane.showMessageDialog(null, "Ngày hẹn không được để trống");
            return;
        }
        String symptom = txtTreatmentSymptom.getText();
        String advice = txtTreatmentAdvice.getText();
        try {
            int diagId = 0;
            if (cbbTreatmentDiagnosis.getSelectedIndex() != 0) {

                String diagnosis = cbbTreatmentDiagnosis.getSelectedItem().toString();
                diagId = treatmentBL.getDiagnosisIdByName(diagnosis);
                if (diagId == -1) {
                    diagId = 0;
                }
            }
            CMDateTime date = utils.Util.convertDateToCMDateTime(myQueryBL, reDate);
            int dayOfUMed = cbbTreatmentDayOfUsingMed.getSelectedIndex() + 1;
            String treCostStr = txtTreatmentCost.getText();
            int treCost = Integer.parseInt(treCostStr.
                    substring(0, treCostStr.indexOf("v")));
            //update kham benh
            int treId = Integer.parseInt(txtTreatmentId.getText());
            if (treId == -1) {
                JOptionPane.showMessageDialog(null, "Mã khám bệnh không hợp lệ");
                return;
            }
            Treatment treatment = treatmentBL.createTreatment();
            treatment.setTreatmentId(treId);
            treatment.setDateOfReTreatment(date);
            treatment.setTreatmentStatusId(3);//đã khám
            treatment.setSymptom(symptom);
            treatment.setDiagnosisId(diagId);
            treatment.setAdvice(advice);
            treatment.setDayOfUsingMedicine(dayOfUMed);
            treatment.setWorkerId(1);
            treatment.setTreatmentCost(treCost);
            treatment.setMedicineCost(0);
            boolean result = treatmentBL.updateTreatment(treatment);

            if (!result) {
                treatmentBL.updateTreatmentStatusId(treId, 1);//có lỗi thì update về chưa khám
                JOptionPane.showMessageDialog(null, "Có lỗi trong quá trình cập nhật");
                return;
            }
            //Add treatment detail
            if (tblTreatmentPrescription.getRowCount() <= 0) {
                JOptionPane.showMessageDialog(null, "Chưa chọn thuốc cho bệnh nhân này");
                treatmentBL.updateTreatmentStatusId(treId, 1);//có lỗi thì update về chưa khám
                return;
            }
            for (int i = 0; i < tblTreatmentPrescription.getRowCount(); i++) {
                TreatmentDetail treDe = treatmentBL.createTreatmentDetail();
                if (treDe == null) {
                    JOptionPane.showMessageDialog(null, "Lỗi cập nhật chi tiết"
                            + " khám bệnh");
                    treatmentBL.updateTreatmentStatusId(treId, 1);//có lỗi thì update về chưa khám
                    return;
                }
                treDe.setTreatmentId(treId);

                //get medid by name
                String[] res = myQueryBL.doQuery("select medicineid from medicine"
                        + " where medicinename= N'" + tblTreatmentPrescription.getValueAt(i, 0).toString() + "'");
                if (res == null || res.length <= 0) {
                    return;
                }
                int medId = Integer.parseInt(res[0]);
                treDe.setMedicinetId(medId);
                //Thuốc sáng
                int med = Integer.parseInt(tblTreatmentPrescription.getValueAt(i, 2).toString());
                treDe.setMorningMed(med);
                //Thuốc trưa
                med = Integer.parseInt(tblTreatmentPrescription.getValueAt(i, 3).toString());
                treDe.setNoonMed(med);
                //Thuốc chiều
                med = Integer.parseInt(tblTreatmentPrescription.getValueAt(i, 4).toString());
                treDe.setAfternoonMed(med);
                //Thuốc tối
                med = Integer.parseInt(tblTreatmentPrescription.getValueAt(i, 5).toString());
                treDe.setEveningMed(med);
                //Tổng số lượng thuốc
                med = Integer.parseInt(tblTreatmentPrescription.getValueAt(i, 6).toString());
                treDe.setQuantity(med);
                //Cách dùng
                String dosage = tblTreatmentPrescription.getValueAt(i, 7).toString();
                treDe.setDosage(dosage);
                //Thành tiền
                int coMoney = getMedCostById(medId);
                int money = coMoney * dayOfUMed * med;

                treDe.setMoney(money);
                boolean re = treatmentBL.addTreatmentDetail(treDe);
                if (!re) {
                    JOptionPane.showMessageDialog(null, "Có lỗi trong quá trình cập nhật"
                            + " thông tin khám bệnh khám bệnh");
                    treatmentBL.updateTreatmentStatusId(treId, 1);//có lỗi thì update về chưa khám
                    return;
                }
            }
            JOptionPane.showMessageDialog(null, "Cập nhật khám bệnh thành công");

        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NumberFormatException ne) {
            JOptionPane.showMessageDialog(null, "Thông tin liều thuốc không hợp lệ");
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ne);
        } 
    }//GEN-LAST:event_btnTreatmentSaveActionPerformed

    private int getMedCostById(int medId) {
        String query = "select cost from medicinedetail"
                + " where medicineid=" + medId;
        try {
            String[] result = myQueryBL.doQuery(query);
            if (result == null || result.length <= 0) {
                return -1;
            }
            return Integer.parseInt(result[0]);
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        } catch (NumberFormatException e) {
            return -1;
        }

    }

    private void tblTreatmentPrescriptionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblTreatmentPrescriptionMouseClicked
        int rowIndex = tblTreatmentPrescription.getSelectedRow();

        if (rowIndex == -1) {
            return;
        }
        //Check if cell has data
        for (int i = 0; i < tblTreatmentPrescription.getColumnCount(); i++) {
            String val = tblTreatmentPrescription.getValueAt(rowIndex, i).toString();
            if (val == null || val.equals("")) {
                return;
            }
        }
        //check if col 0 is selected
        if (tblTreatmentPrescription.getSelectedColumn() == 0) {
            return;
        }
        if (rowIndex == tblTreatmentPrescription.getRowCount() - 1) {
            try {
                //Get ds thuoc
                final Medicine[] med = medicineBL.getAllMedicine();
                if (med == null || med.length <= 0) {
                    JOptionPane.showMessageDialog(null, "Lỗi truy xuất thông tin thuốc");
                    return;
                }
                List<String> listMedName = new ArrayList<>();
                for (int i = 0; i < med.length; i++) {
                    listMedName.add(med[i].getMedicineName());
                }
                JXComboBox comboBox = new JXComboBox();
                comboBox.setModel(new DefaultComboBoxModel(listMedName.toArray()));
                comboBox.addItemListener(new ItemListener() {
                    @Override
                    public void itemStateChanged(ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            //find med by name
                            String name = e.getItem().toString();
                            Medicine medSel = findMedByName(name, med);
                            if (medSel != null) {
                                try {
                                    int medUId = medSel.getMedUnitId();
                                    String medUnitName = medicineBL.getMedUnit(medUId).getMedUnitName();
                                    tblTreatmentPrescription.setValueAt(medUnitName,
                                            tblTreatmentPrescription.getSelectedRow(), 1);
                                    //Make status cell editable
                                    tblTreatmentPrescription.getColumnExt(8).setEditable(true);
                                    String status = medSel.getStatus() == 0 ? "Hết bán" : "Còn bán";
                                    tblTreatmentPrescription.setValueAt(status,
                                            tblTreatmentPrescription.getSelectedRow(), 8);
                                    //Make status cell uneditable
                                    tblTreatmentPrescription.getColumnExt(8).setEditable(false);
                                } catch (GenericUserException ex) {
                                    Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                                }
                            }

                            //int medUnitId = listMed.get
                        }

                    }
                });
                tblTreatmentPrescription.getColumn(0).setCellEditor(new DefaultCellEditor(comboBox));
                String[] colNames = new String[]{"", "", "", "",
                    "", "", "", "", ""};
                DefaultTableModel dt = (DefaultTableModel) tblTreatmentPrescription.getModel();
                dt.addRow(colNames);
            } catch (GenericUserException ex) {
                Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
            }
            //Chen them row moi
        }
    }//GEN-LAST:event_tblTreatmentPrescriptionMouseClicked

    private void cbbTreatmentPrescriptionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbTreatmentPrescriptionItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            int index = cbbTreatmentPrescription.getSelectedIndex();
            if (index != 0) {
                String query = "select MEDICINE.medicinename, MEDICINEUNIT.medicineunitname,"
                        + " medicinemorning, medicinenoon, medicineafternoon,"
                        + " medicineevening, PRESCRIPTIONFORMDETAIL.quantitytotal, dosage,MEDICINE.status"
                        + " from "
                        + " (MEDICINE inner join MEDICINEUNIT on"
                        + " MEDICINE.medicineunitid=MEDICINEUNIT.medicineunitid) inner join"
                        + " PRESCRIPTIONFORMDETAIL on "
                        + " MEDICINE.medicineid=PRESCRIPTIONFORMDETAIL.medicineid "
                        + " where prescriptionid=" + index;
                String[] colNames = new String[]{"Tên thuốc", "Đơn vị", "Sáng", "Trưa",
                    "Chiều", "Tối", "Số lượng", "Cách dùng", "Tình trạng"};
                Hashtable<Integer, Integer> options = new Hashtable<>();
                options.put(8, MED_STATUS);
                try {
                    String[] re = myQueryBL.doQuery(query.toString());
                    if (re == null || re.length <= 0) {
                        return;
                    }
                    fillDataOnTableFromArray(tblTreatmentPrescription, re, colNames, options, true);
                    tblTreatmentPrescription.getColumnExt(8).setEditable(false);
                    final Medicine[] med = medicineBL.getAllMedicine();
                    if (med == null || med.length <= 0) {
                        JOptionPane.showMessageDialog(null, "Lỗi truy xuất thông tin thuốc");
                        return;
                    }
                    List<String> listMedName = new ArrayList<>();
                    for (int i = 0; i < med.length; i++) {
                        listMedName.add(med[i].getMedicineName());
                    }
                    JXComboBox comboBox = new JXComboBox();
                    comboBox.setModel(new DefaultComboBoxModel(listMedName.toArray()));
                    comboBox.addItemListener(new ItemListener() {
                        @Override
                        public void itemStateChanged(ItemEvent e) {
                            if (e.getStateChange() == ItemEvent.SELECTED) {
                                //find med by name
                                String name = e.getItem().toString();
                                Medicine medSel = findMedByName(name, med);
                                if (medSel != null) {
                                    try {
                                        int medUId = medSel.getMedUnitId();
                                        String medUnitName = medicineBL.getMedUnit(medUId).getMedUnitName();
                                        int row = tblTreatmentPrescription.getSelectedRow();
                                        if (row == -1) {
                                            return;
                                        }
                                        tblTreatmentPrescription.setValueAt(medUnitName, row, 1);
                                        //Make status cell editable
                                        tblTreatmentPrescription.getColumnExt(8).setEditable(true);
                                        String status = medSel.getStatus() == 0 ? "Hết bán" : "Còn bán";
                                        tblTreatmentPrescription.setValueAt(status, row, 8);
                                        //Make status cell uneditable
                                        tblTreatmentPrescription.getColumnExt(8).setEditable(false);

                                    } catch (GenericUserException ex) {
                                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                                    }
                                }

                                //int medUnitId = listMed.get
                            }
                        }
                    });
                    tblTreatmentPrescription.getColumn(0).setCellEditor(new DefaultCellEditor(comboBox));
                } catch (GenericUserException ex) {
                    Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }//GEN-LAST:event_cbbTreatmentPrescriptionItemStateChanged

    private void txtTreatmentIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTreatmentIdActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtTreatmentIdActionPerformed

    private void btnTreatmentSearchPaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTreatmentSearchPaActionPerformed
        StringBuilder query = new StringBuilder("select treatmentid, PATIENT.patientid, fullname,"
                + " treatmentstatusid from "
                + " PATIENT inner join TREATMENT on PATIENT.patientid=TREATMENT.patientid "
                + " where ");

        String condi = txtTreatmentSearchPaIdCard.getText();
        if (condi != null && !condi.equals("")) {
            query.append(" idcard = '").append(condi).append("' ");
            searchPatientsAndFillData(query.toString());
            return;
        }
        List<String> liCondi = new ArrayList<>();
        condi = txtTreatmentSearchPaName.getText();
        if (condi != null && !condi.equals("")) {
            liCondi.add(" fullname like '%" + condi + "%' ");
        }

        int sex = cbbTreatmentSearchPaSex.getSelectedIndex();
        if (sex != 0)// find by sex
        {
            if (liCondi.size() > 0) {
                liCondi.add(" and ");
            }
            liCondi.add(" sex=" + (sex - 1) + " ");
        }
        condi = txtTreatmentSearchPaYear.getText();
        if (condi != null && !condi.equals("")) {
            if (liCondi.size() > 0) {
                liCondi.add(" and ");
            }
            liCondi.add(" year(dateofbirth)='" + condi + "' ");
        }
        Date date = dpTreatmentSearchPaDOT.getDate();
        if (date != null)// Find by Date of treatment
        {
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            if (liCondi.size() > 0) {
                liCondi.add(" and ");
            }
            liCondi.add(" year(dateoftreatment)=" + cal.get(Calendar.YEAR) + ""
                    + " and month(dateoftreatment)= " + (cal.get(Calendar.MONTH) + 1) + " "
                    + " and day(dateoftreatment)=" + cal.get(Calendar.DAY_OF_MONTH));
        }
        if (liCondi.size() <= 0) {
            JOptionPane.showMessageDialog(null, "Chưa nhập thông tin tìm kiếm");
            return;
        }
        for (String str : liCondi) {
            query.append(str);
        }
        String[] colNames = new String[]{"Mã Khám","Mã bệnh nhân", "Họ tên", "Tình trạng"};
        Hashtable<Integer, Integer> options = new Hashtable<>();
        options.put(3, TREATMENT_STATUS);
        searchAndFill(tblTreatmentPatients, query.toString(), colNames, options);
    }//GEN-LAST:event_btnTreatmentSearchPaActionPerformed

    private void btnSearchPaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchPaActionPerformed

        StringBuilder query = new StringBuilder("select PATIENT.patientid, fullname, dateofbirth,"
                + " idcard, treatmentstatusid,paystatus from PATIENT inner join TREATMENT on "
                + " PATIENT.patientid=TREATMENT.patientid where ");
//        StringBuilder query = new StringBuilder("select patientid, fullname,"
//                + " dateofbirth, idcard, sex, address from "
//                + " PATIENT where ");
//        String condi = txtSearchPaId.getText();
//        if (condi != null && !condi.equals("")) {
//            query.append(" patientid = ").append(condi).append(" ");
//            searchPatientsAndFillData(query.toString());
//            return;
//        }
//        condi = txtSearchPaIdCard.getText();
//        if (condi != null && !condi.equals("")) {
//            query.append(" idcard = '").append(condi).append("' ");
//            searchPatientsAndFillData(query.toString());
//            return;
//        }
//        ArrayList<String> liCondi = new ArrayList<>();
//        condi = txtSearchPaName.getText();
//        if (condi != null && !condi.equals("")) {
//            liCondi.add(" fullname like '%" + condi + "%' ");
//        }
//
//        int sex = cbbSearchPaSex.getSelectedIndex();
//        if (sex != 0)// find by sex
//        {
//            if (liCondi.size() > 0) {
//                liCondi.add(" and ");
//            }
//            liCondi.add(" sex=" + (sex - 1) + " ");
//        }
//        condi = txtSearchPaYear.getText();
//        if (condi != null && !condi.equals("")) {
//            if (liCondi.size() > 0) {
//                liCondi.add(" and ");
//            }
//            liCondi.add(" year(dateofbirth)='" + condi + "' ");
//        }
//        if (liCondi.size() <= 0) {
//            JOptionPane.showMessageDialog(null, "Chưa nhập thông tin tìm kiếm");
//            return;
//        }
//        for (String str : liCondi) {
//            query.append(str);
//        }
        String qr = createQueryForSearchingPatients(query);
        searchPatientsAndFillData(qr);

    }//GEN-LAST:event_btnSearchPaActionPerformed

    private String createQueryForSearchingPatients(StringBuilder query) {
        String condi = txtSearchPaId.getText();
        if (condi != null && !condi.equals("")) {
            query.append(" PATIENT.patientid = ").append(condi).append(" ");
        } else {
            condi = txtSearchPaIdCard.getText();
            if (condi != null && !condi.equals("")) {
                query.append(" idcard = '").append(condi).append("' ");
            } else {
                ArrayList<String> liCondi = new ArrayList<>();
                condi = txtSearchPaName.getText();
                if (condi != null && !condi.equals("")) {
                    liCondi.add(" fullname like '%" + condi + "%' ");
                }

                int sex = cbbSearchPaSex.getSelectedIndex();
                if (sex != 0)// find by sex
                {
                    if (liCondi.size() > 0) {
                        liCondi.add(" and ");
                    }
                    liCondi.add(" sex=" + (sex - 1) + " ");
                }
                condi = txtSearchPaYear.getText();
                if (condi != null && !condi.equals("")) {
                    if (liCondi.size() > 0) {
                        liCondi.add(" and ");
                    }
                    liCondi.add(" year(dateofbirth)='" + condi + "' ");
                }
                if (liCondi.size() <= 0) {
                    JOptionPane.showMessageDialog(null, "Chưa nhập thông tin tìm kiếm");
                    return null;
                }

                for (String str : liCondi) {
                    query.append(str);
                }
            }
        }
        return query.toString();

    }

    private void datePickerTreatmentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_datePickerTreatmentActionPerformed
        changeWhenDatePickerOfTreatment();
    }//GEN-LAST:event_datePickerTreatmentActionPerformed

    private void changeWhenDatePickerOfTreatment() {
        Date d = datePickerTreatment.getDate();
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        try {
            CMDateTime cmDate = myQueryBL.getCMDateTime(cal.get(Calendar.YEAR),
                    cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));

            String[] colNames = new String[]{"Mã bệnh nhân", "Họ tên", "Năm sinh",
                "CMND", "Tình trạng", "Thanh toán"};
            Hashtable<Integer, Integer> options = new Hashtable<>();
            options.put(4, TREATMENT_STATUS);
            options.put(5, PAY_STATUS);
            fillDataOnTableFromArray(tblPatients, getPatientByDateOfTreatment(cmDate),
                    colNames, options, true);

        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void btnRefreshReceptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshReceptionActionPerformed

        txtPatientIdReception.setText("####");
        txtPatientNameReception.setText("");
        txtPatientAgeReception.setText("");
        datePickerDOB.setDate(null);
        txtPatientWeightReception.setText("");
        cbbPatientSexReception.setSelectedIndex(0);
        txtPatientIdCardReception.setText("");
        txtPatientPhoneReception.setText("");
        txtPatientAddressReception.setText("");
        txtPatientRelativeReception.setText("");
        btnRegisterReception.setText("Đăng ký");
    }//GEN-LAST:event_btnRefreshReceptionActionPerformed

    private void btnRegisterReceptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterReceptionActionPerformed
        boolean isEdit = btnRegisterReception.getText().equals("Sửa") ? true : false;
        if (!isEdit) {
            String paId = txtPatientIdReception.getText();
            if (!paId.equals("####")) {
                JOptionPane.showMessageDialog(null, "Bệnh nhân này đã được đăng ký trước đó");
                return;
            }
        }
        String fullname = txtPatientNameReception.getText();
        if (fullname == null || fullname.equals("")) {
            JOptionPane.showMessageDialog(null, "Tên bệnh nhân không được để trống");
            return;
        }
        String idCard = txtPatientIdCardReception.getText();
        if (idCard == null || idCard.equals("")) {
            JOptionPane.showMessageDialog(null, "CMND không được để trống");
            return;
        }
        Date date = datePickerDOB.getDate();
        if (date == null) {
            date = new Date();
        }
        CMDateTime dob = utils.Util.convertDateToCMDateTime(myQueryBL, date);
        float weight = 0f;
        try {
            weight = Float.parseFloat(txtPatientWeightReception.getText());
            if (weight < 0f) {
                weight = 0f;
            }
        } catch (NumberFormatException ne) {
            weight = 0f;
        }

        Sex sex = cbbPatientSexReception.getSelectedIndex() == 0 ? Sex.Sex_NONE
                : (cbbPatientSexReception.getSelectedIndex() == 1 ? Sex.Sex_MALE : Sex.Sex_FEMALE);
        String address = txtPatientAddressReception.getText();
        String phone = txtPatientPhoneReception.getText();
        String rel = txtPatientRelativeReception.getText();

        try {
            Patient patient = patientBL.createPatient();
            patient.setFullName(fullname);
            patient.setAddress(address);
            patient.setDateOfBirth(dob);
            patient.setIdCard(idCard);
            patient.setPhoneNumber(phone);
            patient.setRelative(rel);
            patient.setSex(sex);
            if (isEdit) {
                int id = Integer.parseInt(txtPatientIdReception.getText());
                patient.setPatientId(id);
                boolean re = patientBL.updatePatient(patient);
                if (!re) {
                    JOptionPane.showMessageDialog(null, "Có lỗi trong quá trình xử lý.");
                    btnRefreshReception.setVisible(true);
                    btnRegisterReception.setText("Sửa");
                } else {
                    JOptionPane.showMessageDialog(null, "Cập nhật bệnh nhân mới thành công");
                    //refresh table
                    changeWhenDatePickerOfTreatment();
                }
            } else {
                int id = patientBL.addPatient(patient);
                txtPatientIdReception.setText(id + "");
                if (id != -1)// Add Ok
                {
                    //add kham benh
                    Treatment treatment = treatmentBL.createTreatment();
                    treatment.setPatientId(id);
                    Date c = Calendar.getInstance().getTime();
                    treatment.setDateOfTreatment(utils.Util.convertDateToCMDateTime(myQueryBL, c));
                    treatment.setWeight(weight);
                    treatment.setTreatmentStatusId(1);//chưa khám
                    treatment.setSymptom("");
                    treatment.setDiagnosisId(0);
                    treatment.setAdvice("");
                    treatment.setDateOfReTreatment(utils.Util.convertDateToCMDateTime(myQueryBL, c));
                    treatment.setDayOfUsingMedicine(0);
                    treatment.setWorkerId(1);
                    treatment.setTreatmentCost(0);
                    treatment.setMedicineCost(0);
                    treatment.setPayStatus((short) 0);
                    int tId = treatmentBL.addTreatment(treatment);
                    if (tId != -1) {
                        JOptionPane.showMessageDialog(null, "Thêm bệnh nhân mới thành công");
                        //refresh table
                        changeWhenDatePickerOfTreatment();
                    } else {
                        JOptionPane.showMessageDialog(null, "Thêm bệnh nhân mới thành công tuy nhiên,"
                                + " thông tin khám bệnh chưa được cập nhật");
                        //refresh table
                        changeWhenDatePickerOfTreatment();
                    }
                    btnRefreshReception.setVisible(true);
                    btnRegisterReception.setText("Sửa");
                } else {
                    JOptionPane.showMessageDialog(null, "Có lỗi trong quá trình thêm bệnh nhân");
                }
            }
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class
                    .getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(
                    null, "Có lỗi trong quá trình xử lý.");
            btnRefreshReception.setVisible(
                    false);
        }
    }//GEN-LAST:event_btnRegisterReceptionActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    }//GEN-LAST:event_formWindowClosing

    private void datePickerDOBPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_datePickerDOBPropertyChange
        Date d = datePickerDOB.getDate();
        if (d == null) {
            return;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        int curYear = Calendar.getInstance().get(Calendar.YEAR);
        int dob = cal.get(Calendar.YEAR);
        int age = curYear - dob;
        if (age < 0) {
            JOptionPane.showMessageDialog(null, "Năm sinh vượt quá năm hiện tại.");
        } else {
            txtPatientAgeReception.setText(age + "");
        }
    }//GEN-LAST:event_datePickerDOBPropertyChange

    private void tblTreatmentPrescriptionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblTreatmentPrescriptionKeyPressed
    }//GEN-LAST:event_tblTreatmentPrescriptionKeyPressed

    private void tblTreatmentPrescriptionKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblTreatmentPrescriptionKeyReleased
        if (evt.getKeyChar() == KeyEvent.VK_TAB) {
            int col = tblTreatmentPrescription.getSelectedColumn();
            int row = tblTreatmentPrescription.getSelectedRow();
            String morning = tblTreatmentPrescription.getValueAt(row, 2).toString();
            String noon = tblTreatmentPrescription.getValueAt(row, 3).toString();
            String afternoon = tblTreatmentPrescription.getValueAt(row, 4).toString();
            String evening = tblTreatmentPrescription.getValueAt(row, 5).toString();
            if (morning == null || morning.equals("")) {
                tblTreatmentPrescription.setValueAt(0, row, 2);
            }
            int mor = Integer.parseInt(tblTreatmentPrescription.getValueAt(row, 2).toString());

            if (noon == null || noon.equals("")) {
                tblTreatmentPrescription.setValueAt(0, row, 3);
            }
            int no = Integer.parseInt(tblTreatmentPrescription.getValueAt(row, 3).toString());

            if (afternoon == null || afternoon.equals("")) {
                tblTreatmentPrescription.setValueAt(0, row, 4);
            }
            int af = Integer.parseInt(tblTreatmentPrescription.getValueAt(row, 4).toString());
            if (evening == null || evening.equals("")) {
                tblTreatmentPrescription.setValueAt(0, row, 5);
            }
            int ev = Integer.parseInt(tblTreatmentPrescription.getValueAt(row, 5).toString());

            int quan = mor + no + af + ev;
            tblTreatmentPrescription.setValueAt(quan, row, 6);
        }
    }//GEN-LAST:event_tblTreatmentPrescriptionKeyReleased

    private void btnTreatmentMedCostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTreatmentMedCostActionPerformed
        int dayOfUMed = cbbTreatmentDayOfUsingMed.getSelectedIndex() + 1;
        for (int i = 0; i < tblTreatmentPrescription.getRowCount(); i++) {
            //get medid by name
            String[] res;
            try {
                res = myQueryBL.doQuery("select medicineid from medicine"
                        + " where medicinename= N'" + tblTreatmentPrescription.getValueAt(i, 0).toString() + "'");
                if (res == null || res.length <= 0) {
                    return;
                }
                int medId = Integer.parseInt(res[0]);
                //Tổng số lượng thuốc
                int medQuan = Integer.parseInt(tblTreatmentPrescription.getValueAt(i, 6).toString());
                //Thành tiền
                int coMoney = getMedCostById(medId);
                int money = coMoney * dayOfUMed * medQuan;

                txtTreatmentMedCost.setText(money + "vnd");
            } catch (GenericUserException ex) {
                Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    }//GEN-LAST:event_btnTreatmentMedCostActionPerformed

    private void btnDiagnosisSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDiagnosisSaveActionPerformed
        String name = txtDiagnosisName.getText();
        if (name.equals("")) {
            JOptionPane.showMessageDialog(null, "Tên chẩn đoán không hợp lệ.");
            return;
        }
        try {
            boolean re = treatmentBL.addDiagnosis(name);
            if (!re) {
                JOptionPane.showMessageDialog(null, "Lỗi máy chủ, không thể thêm chẩn đoán.");
            } else {
                JOptionPane.showMessageDialog(null, "Thêm chẩn đoán thành công.");
            }
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnDiagnosisSaveActionPerformed

    private void tblDiagnosisMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblDiagnosisMouseClicked
        int rowIndex = tblDiagnosis.getSelectedRow();
        if (rowIndex == -1) {
            return;
        }
        String name = tblDiagnosis.getValueAt(rowIndex, 0).toString();
        txtDiagnosisName.setText(name);
        btnDiagnosisUpdate.setEnabled(true);

    }//GEN-LAST:event_tblDiagnosisMouseClicked

    private void btnDiagnosisUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDiagnosisUpdateActionPerformed
        int diaId;
        String oldName = tblDiagnosis.getValueAt(tblDiagnosis.getSelectedRow(), 0).toString();
        try {
            diaId = treatmentBL.getDiagnosisIdByName(oldName);
            if (diaId == -1) {
                JOptionPane.showMessageDialog(null, "Cập nhật không thành công");
                return;
            }
            String newName = txtDiagnosisName.getText();
            boolean re = treatmentBL.updateDiagnosis(diaId, newName);
            if (re) {
                JOptionPane.showMessageDialog(null, "Cập nhật thành công");
            } else {
                JOptionPane.showMessageDialog(null, "Cập nhật không thành công");
            }
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnDiagnosisUpdateActionPerformed

    private void btnWorkerSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkerSearchActionPerformed

        StringBuilder query = new StringBuilder("select workerid, fullname, dateofbirth "
                + " from "
                + " WORKER "
                + " where ");

        String condi = txtWorkerId.getText();
        if (condi != null && !condi.equals("")) {
            query.append(" workerid = ").append(condi);
            String[] colNames = new String[]{"Mã nhân viên", "Họ tên", "Ngày sinh"};
            searchAndFill(tblWorkerSearchResult, query.toString(), colNames, null);
            return;
        }
        List<String> liCondi = new ArrayList<>();
        condi = txtWorkerName.getText();
        if (condi != null && !condi.equals("")) {
            liCondi.add(" fullname like '%" + condi + "%' ");
        }

        condi = txtWorkerYear.getText();
        if (condi != null && !condi.equals("")) {
            if (liCondi.size() > 0) {
                liCondi.add(" and ");
            }
            liCondi.add(" year(dateofbirth)='" + condi + "' ");
        }
        int position = cbbWorkerGroup.getSelectedIndex();
        if (position != 0)// find by group
        {
            if (liCondi.size() > 0) {
                liCondi.add(" and ");
            }
            liCondi.add(" positionid=" + (position) + " ");
        }
        int status = cbbWorkerStatus.getSelectedIndex();
        if (status != 0)// find by status
        {
            if (liCondi.size() > 0) {
                liCondi.add(" and ");
            }
            if (status == 2)//nghi lam
            {
                status = 0;
            }
            liCondi.add(" status=" + (status) + " ");
        }
        if (liCondi.size() <= 0) {
            JOptionPane.showMessageDialog(null, "Chưa nhập thông tin tìm kiếm");
            return;
        }
        for (String str : liCondi) {
            query.append(str);
        }
        String[] colNames = new String[]{"Mã nhân viên", "Họ tên", "Ngày sinh"};
        searchAndFill(tblWorkerSearchResult, query.toString(), colNames, null);
    }//GEN-LAST:event_btnWorkerSearchActionPerformed

    private void dpWorkerMainDOBPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_dpWorkerMainDOBPropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_dpWorkerMainDOBPropertyChange

    private void tblWorkerSearchResultMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblWorkerSearchResultMouseClicked
        int rowIndex = tblWorkerSearchResult.getSelectedRow();
        if (rowIndex == -1) {
            return;
        }

        try {
            int workerId = Integer.parseInt(tblWorkerSearchResult.getValueAt(rowIndex, 0).toString());
            Worker worker = workerBL.getWorkerById(workerId);
            fillWorker(worker);
            txtWorkerMainUser.setEnabled(false);
            btnWorkerMainUpdate.setEnabled(true);
            btnWorkerMainSave.setEnabled(false);
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NumberFormatException ne) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ne);
        }
    }//GEN-LAST:event_tblWorkerSearchResultMouseClicked

    private void tblWorkerMainMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblWorkerMainMouseClicked
        int rowIndex = tblWorkerMain.getSelectedRow();
        if (rowIndex == -1) {
            return;
        }

        try {
            int workerId = Integer.parseInt(tblWorkerMain.getValueAt(rowIndex, 0).toString());
            Worker worker = workerBL.getWorkerById(workerId);
            fillWorker(worker);
            txtWorkerMainUser.setEnabled(false);
            btnWorkerMainUpdate.setEnabled(true);
            btnWorkerMainSave.setEnabled(false);
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NumberFormatException ne) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ne);
        }
    }//GEN-LAST:event_tblWorkerMainMouseClicked

    private void btnWorkerMainUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkerMainUpdateActionPerformed
        int id = Integer.parseInt(txtWorkerMainId.getText());
        if (id == -1) {
            return;
        }
        try {
            Worker tempW = workerBL.getWorkerById(id);
            String name = txtWorkerMainName.getText();
            if (!name.equals("")) {
                tempW.setFullName(name);
            }
            String address = txtWorkerMainAddress.getText();
            if (!address.equals("")) {
                tempW.setAddress(address);
            }
            String idcard = txtWorkerMainIdCard.getText();
            if (!idcard.equals("")) {
                tempW.setIdCard(idcard);
            }
            String phone = txtWorkerMainPhone.getText();
            if (!phone.equals("")) {
                tempW.setPhoneNumber(phone);
            }
            String pass = txtWorkerMainPass.getText();
            if (!pass.equals("")) {
                tempW.setPassword(pass);
            }
            int sex = cbbWorkerMainSex.getSelectedIndex();
            if (sex != 0) {
                Sex s = Sex.Sex_NONE;
                if (sex == 2) {
                    s = Sex.Sex_MALE;
                } else {
                    s = Sex.Sex_FEMALE;
                }
                tempW.setSex(s);
            }
            Date d = dpWorkerMainDOB.getDate();
            if (d != null) {
                CMDateTime dob = utils.Util.convertDateToCMDateTime(myQueryBL, d);
                tempW.setDateOfBirth(dob);
            }
            int positionId = cbbWorkerMainGroup.getSelectedIndex();
            if (positionId != 0) {
                tempW.setPositionId(positionId);
            }
            int status = cbbWorkerMainStatus.getSelectedIndex();
            if (status != 0) {
                if (status == 2) {
                    status = 0;
                }
                tempW.setStatus((short) status);
            }
            boolean re = workerBL.updateWorker(tempW);
            if (!re) {
                JOptionPane.showMessageDialog(null, "Lỗi cập nhật nhân viên");
            } else {
                JOptionPane.showMessageDialog(null, "Cập nhật nhân viên thành công");
            }

        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_btnWorkerMainUpdateActionPerformed

    private void btnWorkerMainNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkerMainNewActionPerformed
        txtWorkerMainId.setText("####");
        txtWorkerMainName.setText("");
        txtWorkerMainAddress.setText("");
        txtWorkerMainIdCard.setText("");
        txtWorkerMainPhone.setText("");
        txtWorkerMainUser.setText("");
        txtWorkerMainUser.setEnabled(true);
        txtWorkerMainPass.setText("");

        cbbWorkerMainSex.setSelectedIndex(0);
        cbbWorkerMainGroup.setSelectedIndex(0);
        cbbWorkerMainStatus.setSelectedIndex(1);

        dpWorkerMainDOB.setDate(null);

        btnWorkerMainSave.setEnabled(true);
        btnWorkerMainUpdate.setEnabled(false);
    }//GEN-LAST:event_btnWorkerMainNewActionPerformed

    private void btnWorkerMainSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkerMainSaveActionPerformed
        try {
            Worker worker = workerBL.createWorker();
            String name = txtWorkerMainName.getText();
            if (!name.equals("")) {
                worker.setFullName(name);
            } else {
                JOptionPane.showMessageDialog(null, "Tên nhân viên không được rỗng");
                return;
            }
            String address = txtWorkerMainAddress.getText();
            if (!address.equals("")) {
                worker.setAddress(address);
            } else {
                JOptionPane.showMessageDialog(null, "Địa chỉ nhân viên không được rỗng");
                return;
            }
            String idcard = txtWorkerMainIdCard.getText();
            if (!idcard.equals("")) {
                worker.setIdCard(idcard);
            } else {
                JOptionPane.showMessageDialog(null, "Số chứng minh không được rỗng");
                return;
            }
            String phone = txtWorkerMainPhone.getText();
            if (!phone.equals("")) {
                worker.setPhoneNumber(phone);
            } else {
                JOptionPane.showMessageDialog(null, "Số điện thoại nhân viên không được rỗng");
                return;
            }
            String username = txtWorkerMainUser.getText();
            if (!username.equals("")) {
                worker.setUsername(username);
            } else {
                JOptionPane.showMessageDialog(null, "Tên đăng nhập nhân viên không được rỗng");
                return;
            }
            String pass = txtWorkerMainPass.getText();
            if (!pass.equals("")) {
                worker.setPassword(pass);
            } else {
                JOptionPane.showMessageDialog(null, "Mật khẩu nhân viên không được rỗng");
                return;
            }
            int sex = cbbWorkerMainSex.getSelectedIndex();
            if (sex != 0) {
                Sex s = Sex.Sex_NONE;
                if (sex == 2) {
                    s = Sex.Sex_MALE;
                } else {
                    s = Sex.Sex_FEMALE;
                }
                worker.setSex(s);
            } else {
                JOptionPane.showMessageDialog(null, "Chưa chọn giới tính nhân viên");
                return;
            }
            Date d = dpWorkerMainDOB.getDate();
            if (d != null) {
                CMDateTime dob = utils.Util.convertDateToCMDateTime(myQueryBL, d);
                worker.setDateOfBirth(dob);
            } else {
                JOptionPane.showMessageDialog(null, "Chưa chọn ngày sinh nhân viên");
                return;
            }
            int positionId = cbbWorkerMainGroup.getSelectedIndex();
            if (positionId != 0) {
                worker.setPositionId(positionId);
            } else {
                JOptionPane.showMessageDialog(null, "Chưa chọn nhóm nhân viên");
                return;
            }
            int status = cbbWorkerMainStatus.getSelectedIndex();
            if (status != 0) {
                if (status == 2) {
                    status = 0;
                }
                worker.setStatus((short) status);
            } else {
                JOptionPane.showMessageDialog(null, "Trạng thái nhân viên không hợp lệ");
                return;
            }
            int id = workerBL.addWorker(worker);
            if (id == -1) {
                JOptionPane.showMessageDialog(null, "Lỗi thêm nhân viên");
            } else {
                JOptionPane.showMessageDialog(null, "Thêm nhật nhân viên thành công");
                txtWorkerMainId.setText(id + "");
                btnWorkerMainSave.setEnabled(false);
                btnWorkerMainUpdate.setEnabled(true);
                txtWorkerMainUser.setEnabled(false);
            }

        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_btnWorkerMainSaveActionPerformed

    private void btnReTreatmentReceptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReTreatmentReceptionActionPerformed
        int rowIndex = tblPatients.getSelectedRow();
        if (rowIndex == -1) {
            JOptionPane.showMessageDialog(null, "Chưa chọn bệnh nhân");
            return;
        }
        String value = tblPatients.getValueAt(rowIndex, 4).toString();
            Date date = new Date();
            CMDateTime cd = utils.Util.convertDateToCMDateTime(myQueryBL, date);
            int paId = Integer.parseInt(tblPatients.getValueAt(rowIndex, 0).toString());
            try {
                //check if patient has been added
                String query = "select patientid from treatment where year(dateoftreatment) = "
                        + cd.getYear() + " and month(dateoftreatment)=" + cd.getMonth()
                        + " and day(dateoftreatment)=" + cd.getDay()
                        + " and treatmentstatusid !=" + 3// added
                        + " and patientid="+paId;
                String[] re = myQueryBL.doQuery(query);
                if (re == null || re.length <= 0)//not added
                {
                    //add kham benh

                    int tId = initNewTreatment();
                    if (tId != -1) {
                        JOptionPane.showMessageDialog(null, "Thêm thông tin tái khám thành công");
                    } else {
                        JOptionPane.showMessageDialog(null, "Thêm tái khám không thành công");
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "Bệnh nhân đã được đăng ký tái khám."
                            + " Không cần đăng ký lại.");
                }
            } catch (GenericUserException ex) {
                Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
            }
        
    }//GEN-LAST:event_btnReTreatmentReceptionActionPerformed

    private void tblPatientsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblPatientsMouseClicked
        int rowIndex = tblPatients.getSelectedRow();
        if (rowIndex == -1) {
            return;
        }
        int paId = Integer.parseInt(tblPatients.getValueAt(rowIndex, 0).toString());
        try {
            Patient p = patientBL.getPatientById(paId);
            if (p == null) {
                return;
            }
            //fill data
            txtPatientIdReception.setText(paId + "");
            txtPatientAddressReception.setText(p.getAddress());
            txtPatientIdCardReception.setText(p.getIdCard());
            txtPatientNameReception.setText(p.getFullName());
            txtPatientPhoneReception.setText(p.getPhoneNumber());
            txtPatientRelativeReception.setText(p.getRelative());

            CMDateTime cd = p.getDateOfBirth();
            datePickerDOB.setDate(utils.Util.convertCMDateTimeToDate(cd));

            Sex s = p.getSex();
            int sexIndex = (int) s.value();
            cbbPatientSexReception.setSelectedIndex(sexIndex);
            //get weight
            String query = "select weight from treatment where patientid=" + paId;
            String[] re = myQueryBL.doQuery(query);
            if (re == null || re.length <= 0) {
                txtPatientWeightReception.setText(0 + "");
            } else {
                float weight = Float.parseFloat(re[0]);
                txtPatientWeightReception.setText(weight + "");
            }
            //Change register button to edit
            btnRegisterReception.setText("Sửa");
            //Enable retreatment button
            btnReTreatmentReception.setEnabled(true);
            //
            btnRefreshReception.setVisible(true);

        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_tblPatientsMouseClicked
    boolean tabTiepNhan = false;
    private void lbTiepNhanMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbTiepNhanMouseClicked
        if(!tabTiepNhan){
            tabParent.addTab("Tiếp nhận", TiepNhan);
            tabTiepNhan = true;
        }
        tabParent.setSelectedComponent(TiepNhan);
    }//GEN-LAST:event_lbTiepNhanMouseClicked
    boolean tabHoSoBenhAn = false;
    private void lbBenhAnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbBenhAnMouseClicked
        if(!tabHoSoBenhAn){
            tabParent.addTab("Hồ sơ bệnh án", HoSoBenhAn);
            tabHoSoBenhAn = true;
        }
        tabParent.setSelectedComponent(HoSoBenhAn);
    }//GEN-LAST:event_lbBenhAnMouseClicked

    private void lbThoatMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbThoatMouseClicked
        this.dispose();
    }//GEN-LAST:event_lbThoatMouseClicked
    boolean tabThanhToan = false;
    private void lbThanhToanMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbThanhToanMouseClicked
        if(!tabThanhToan){
            tabParent.addTab("Thanh toán", ThanhToan);
            tabThanhToan = true;
        }
        tabParent.setSelectedComponent(ThanhToan);
    }//GEN-LAST:event_lbThanhToanMouseClicked
    boolean tabNhapKho = false;
    private void lbNhapKhoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbNhapKhoMouseClicked
        if(!tabNhapKho){
            tabParent.addTab("Nhập kho", NhapKho);
            tabNhapKho = true;
        }
        tabParent.setSelectedComponent(NhapKho);
    }//GEN-LAST:event_lbNhapKhoMouseClicked
    boolean tabBaoCao = false;
    private void lbBaoCaoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbBaoCaoMouseClicked
        if(!tabBaoCao){
            tabParent.addTab("Báo cáo doanh thu", BaoCaoDoanhThu);
            tabBaoCao = true;
        }
        tabParent.setSelectedComponent(BaoCaoDoanhThu);
    }//GEN-LAST:event_lbBaoCaoMouseClicked
    boolean tabDanhMuc = false;
    private void lbDanhMucMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbDanhMucMouseClicked
         if(!tabDanhMuc){
            tabParent.addTab("Khai báo toa mẫu", KhaiBaoToaMau);
            tabParent.addTab("Thuốc - vật tư y tế", KhaiBaoVatTu);
            tabParent.addTab("Chuẩn đoán bệnh", ChuanDoanBenh);
            tabParent.addTab("Phân quyền", PhanQuyen);
            tabParent.addTab("Nhân viên bác sỹ", NhanVienBacSy);
            tabDanhMuc = true;
        }
        tabParent.setSelectedComponent(KhaiBaoToaMau);
    }//GEN-LAST:event_lbDanhMucMouseClicked
    private void login(){
        String username = txtUserName.getText();
        char[] password = txtPassword.getPassword();
        String pass = String.copyValueOf(password);
        if(username.length() <5 || username.equals("")){
            JOptionPane.showMessageDialog(null, "Chưa nhập tài khoản hoặc tài khoản không hợp lệ.");
            return;
        }
        if(password.equals("")){
            JOptionPane.showMessageDialog(null, "Chưa nhập mật khẩu.");
            return;
        }
        try {
            boolean login = workerBL.checkLogin(username, pass);
            if(login){
                panelLogin.setVisible(false);
            }else{
                JOptionPane.showMessageDialog(null, "Tài khoản hoặc mật khẩu không hợp lệ.");
            }
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    private void btnDangNhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDangNhapActionPerformed
        login();
    }//GEN-LAST:event_btnDangNhapActionPerformed

    private void txtPasswordKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPasswordKeyPressed
        if(evt.getKeyCode() == KeyEvent.VK_ENTER){
            login();
        }
    }//GEN-LAST:event_txtPasswordKeyPressed

    private void txtUserNameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtUserNameKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            login();
        }
    }//GEN-LAST:event_txtUserNameKeyPressed

    private int initNewTreatment() {
        try {
            int id = Integer.parseInt(txtPatientIdReception.getText());
            if (id == -1) {
                return -1;
            }
            Treatment treatment = treatmentBL.createTreatment();
            treatment.setPatientId(id);
            Date c = Calendar.getInstance().getTime();
            treatment.setDateOfTreatment(utils.Util.convertDateToCMDateTime(myQueryBL, c));
            float weight = Float.parseFloat(txtPatientWeightReception.getText());
            treatment.setWeight(weight);
            treatment.setTreatmentStatusId(1);//chưa khám
            treatment.setSymptom("");
            treatment.setDiagnosisId(0);
            treatment.setAdvice("");
            treatment.setDateOfReTreatment(utils.Util.convertDateToCMDateTime(myQueryBL, c));
            treatment.setDayOfUsingMedicine(0);
            treatment.setWorkerId(1);
            treatment.setTreatmentCost(0);
            treatment.setMedicineCost(0);
            treatment.setPayStatus((short) 0);
            int tId = treatmentBL.addTreatment(treatment);
            if (tId != -1) {
                return tId;
            } else {
                return -1;
            }
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        }
    }

    private void fillWorker(Worker worker) throws GenericUserException {
        if (worker == null) {
            return;
        }
        txtWorkerMainId.setText(worker.getWorkerId() + "");
        txtWorkerMainName.setText(worker.getFullName() + "");
        txtWorkerMainAddress.setText(worker.getAddress() + "");
        txtWorkerMainIdCard.setText(worker.getIdCard() + "");
        txtWorkerMainPhone.setText(worker.getPhoneNumber() + "");
        txtWorkerMainUser.setText(worker.getUsername() + "");
        txtWorkerMainPass.setText(worker.getPassword() + "");

        int sex = worker.getSex() == Sex.Sex_NONE ? 1
                : (worker.getSex() == Sex.Sex_MALE ? 2 : 3);
        cbbWorkerMainSex.setSelectedIndex(sex);
        cbbWorkerMainGroup.setSelectedIndex(worker.getPositionId());
        int status = worker.getStatus();
        if (status == 0)//nghi lam
        {
            status = 2;
        }
        cbbWorkerMainStatus.setSelectedIndex(status);
        CMDateTime dob = worker.getDateOfBirth();
        Date d = utils.Util.convertCMDateTimeToDate(dob);
        dpWorkerMainDOB.setDate(d);

    }

    private String[] getPatientByDateOfTreatment(CMDateTime cmDate) throws GenericUserException {
        String query = "select PATIENT.patientid, fullname, dateofbirth,"
                + " idcard, treatmentstatusid,paystatus from PATIENT inner join TREATMENT on "
                + " PATIENT.patientid=TREATMENT.patientid where "
                + "year(dateoftreatment)= " + cmDate.getYear() + " "
                + "and month(dateoftreatment)= " + (cmDate.getMonth() + 1) + " "
                + "and day(dateoftreatment)= " + cmDate.getDay();

        return myQueryBL.doQuery(query);
    }

    private void searchPatientsAndFillData(String query) {
        try {
            String[] colNames = new String[]{"Mã bệnh nhân", "Họ tên", "Năm sinh",
                "CMND", "Tình trạng", "Thanh toán"};
            Hashtable<Integer, Integer> options = new Hashtable<>();
            options.put(4, TREATMENT_STATUS);
            options.put(5, PAY_STATUS);
            String[] re = myQueryBL.doQuery(query);
            fillDataOnTableFromArray(tblPatients, re,
                    colNames, options, true);
            if (re == null || re.length <= 0) {
                //search in patient
                StringBuilder prequery = new StringBuilder("select patientid, fullname,"
                        + " dateofbirth, idcard, sex, address from "
                        + " PATIENT where ");
                String qr = createQueryForSearchingPatients(prequery);
                Patient[] lp = patientBL.getPatientsByRawQuery(qr);
                if (lp == null || lp.length <= 0) {
                    JOptionPane.showMessageDialog(null, "Không tìm thấy bệnh nhân");
                } else {
                    JOptionPane.showMessageDialog(null, "Bệnh nhân có tồn tại trong dữ liệu, tuy nhiên"
                            + " không có thông tin khám bệnh. \n"
                            + " Chọn cập nhật thông tin khám bệnh mới để thêm thông tin khám bệnh.");
                    fillDataOnPatientTable(tblPatients, lp);
                }
            }
        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
    }

    private boolean searchAndFill(JXTable table, String query, String[] colNames,
            Hashtable<Integer, Integer> options) {
        try {
            String[] result = myQueryBL.doQuery(query);
            if (result == null || result.length <= 0) {
                JOptionPane.showMessageDialog(null, "Không tìm thấy kết quả");
                return false;
            }
            fillDataOnTableFromArray(table, result, colNames, options, true);
            return true;


        } catch (GenericUserException ex) {
            Logger.getLogger(MainForm.class
                    .getName()).log(Level.SEVERE, null, ex);

            return false;
        }
    }

    private Medicine findMedByName(String name, Medicine[] med) {

        for (int i = 0; i < med.length; i++) {
            try {
                if (med[i].getMedicineName().equals(name)) {
                    return med[i];
                }
            } catch (GenericUserException ex) {
                Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                return null;
            }
        }
        return null;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

        } catch (Exception e) {
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel BaoCaoDoanhThu;
    private javax.swing.JPanel ChuanDoanBenh;
    private javax.swing.JPanel DangNhap;
    private javax.swing.JPanel HoSoBenhAn;
    private javax.swing.JPanel KhaiBaoToaMau;
    private javax.swing.JPanel KhaiBaoVatTu;
    private javax.swing.JPanel NhanVienBacSy;
    private javax.swing.JPanel NhapKho;
    private javax.swing.JPanel PhanQuyen;
    private javax.swing.JTabbedPane TabMenuBar;
    private javax.swing.JPanel ThanhToan;
    private javax.swing.JPanel TiepNhan;
    private javax.swing.JButton btnDangNhap;
    private javax.swing.JButton btnDiagnosisSave;
    private javax.swing.JButton btnDiagnosisUpdate;
    private javax.swing.JButton btnReTreatmentReception;
    private javax.swing.JButton btnRefreshReception;
    private javax.swing.JButton btnRegisterReception;
    private javax.swing.JButton btnSearchPa;
    private javax.swing.JButton btnTreatmentMedCost;
    private javax.swing.JButton btnTreatmentPrint;
    private javax.swing.JButton btnTreatmentSave;
    private javax.swing.JButton btnTreatmentSearchPa;
    private javax.swing.JButton btnWorkerMainNew;
    private javax.swing.JButton btnWorkerMainSave;
    private javax.swing.JButton btnWorkerMainUpdate;
    private javax.swing.JButton btnWorkerSearch;
    private javax.swing.JComboBox cbbPatientSexReception;
    private javax.swing.JComboBox cbbSearchPaSex;
    private javax.swing.JComboBox cbbTreatmentDayOfUsingMed;
    private javax.swing.JComboBox cbbTreatmentDiagnosis;
    private javax.swing.JComboBox cbbTreatmentPaSex;
    private javax.swing.JComboBox cbbTreatmentPrescription;
    private javax.swing.JComboBox cbbTreatmentSearchPaSex;
    private javax.swing.JComboBox cbbTreatmentStatus;
    private javax.swing.JComboBox cbbWorkerGroup;
    private javax.swing.JComboBox cbbWorkerMainGroup;
    private javax.swing.JComboBox cbbWorkerMainSex;
    private javax.swing.JComboBox cbbWorkerMainStatus;
    private javax.swing.JComboBox cbbWorkerStatus;
    private org.jdesktop.swingx.JXDatePicker datePickerDOB;
    private org.jdesktop.swingx.JXDatePicker datePickerTreatment;
    private org.jdesktop.swingx.JXDatePicker dpTreatmentDOReT;
    private org.jdesktop.swingx.JXDatePicker dpTreatmentSearchPaDOT;
    private org.jdesktop.swingx.JXDatePicker dpWorkerMainDOB;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox10;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JComboBox jComboBox6;
    private javax.swing.JComboBox jComboBox7;
    private javax.swing.JComboBox jComboBox8;
    private javax.swing.JComboBox jComboBox9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel100;
    private javax.swing.JLabel jLabel101;
    private javax.swing.JLabel jLabel102;
    private javax.swing.JLabel jLabel103;
    private javax.swing.JLabel jLabel104;
    private javax.swing.JLabel jLabel105;
    private javax.swing.JLabel jLabel106;
    private javax.swing.JLabel jLabel107;
    private javax.swing.JLabel jLabel108;
    private javax.swing.JLabel jLabel109;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel110;
    private javax.swing.JLabel jLabel111;
    private javax.swing.JLabel jLabel112;
    private javax.swing.JLabel jLabel113;
    private javax.swing.JLabel jLabel114;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel53;
    private javax.swing.JLabel jLabel54;
    private javax.swing.JLabel jLabel55;
    private javax.swing.JLabel jLabel56;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JLabel jLabel58;
    private javax.swing.JLabel jLabel59;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel60;
    private javax.swing.JLabel jLabel61;
    private javax.swing.JLabel jLabel62;
    private javax.swing.JLabel jLabel63;
    private javax.swing.JLabel jLabel64;
    private javax.swing.JLabel jLabel65;
    private javax.swing.JLabel jLabel66;
    private javax.swing.JLabel jLabel67;
    private javax.swing.JLabel jLabel68;
    private javax.swing.JLabel jLabel69;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel70;
    private javax.swing.JLabel jLabel71;
    private javax.swing.JLabel jLabel72;
    private javax.swing.JLabel jLabel73;
    private javax.swing.JLabel jLabel74;
    private javax.swing.JLabel jLabel75;
    private javax.swing.JLabel jLabel76;
    private javax.swing.JLabel jLabel77;
    private javax.swing.JLabel jLabel78;
    private javax.swing.JLabel jLabel79;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel80;
    private javax.swing.JLabel jLabel81;
    private javax.swing.JLabel jLabel82;
    private javax.swing.JLabel jLabel83;
    private javax.swing.JLabel jLabel84;
    private javax.swing.JLabel jLabel85;
    private javax.swing.JLabel jLabel86;
    private javax.swing.JLabel jLabel87;
    private javax.swing.JLabel jLabel88;
    private javax.swing.JLabel jLabel89;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabel90;
    private javax.swing.JLabel jLabel91;
    private javax.swing.JLabel jLabel92;
    private javax.swing.JLabel jLabel93;
    private javax.swing.JLabel jLabel94;
    private javax.swing.JLabel jLabel95;
    private javax.swing.JLabel jLabel96;
    private javax.swing.JLabel jLabel97;
    private javax.swing.JLabel jLabel98;
    private javax.swing.JLabel jLabel99;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel26;
    private javax.swing.JPanel jPanel27;
    private javax.swing.JPanel jPanel28;
    private javax.swing.JPanel jPanel29;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel30;
    private javax.swing.JPanel jPanel31;
    private javax.swing.JPanel jPanel32;
    private javax.swing.JPanel jPanel33;
    private javax.swing.JPanel jPanel34;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane15;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField15;
    private javax.swing.JTextField jTextField16;
    private javax.swing.JTextField jTextField17;
    private javax.swing.JTextField jTextField18;
    private javax.swing.JTextField jTextField19;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField20;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JToolBar jToolBar3;
    private javax.swing.JToolBar jToolBar4;
    private javax.swing.JToolBar jToolBar5;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker1;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker2;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker3;
    private org.jdesktop.swingx.JXTable jXTable1;
    private org.jdesktop.swingx.JXTable jXTable10;
    private org.jdesktop.swingx.JXTable jXTable11;
    private org.jdesktop.swingx.JXTable jXTable2;
    private org.jdesktop.swingx.JXTable jXTable3;
    private org.jdesktop.swingx.JXTable jXTable4;
    private org.jdesktop.swingx.JXTable jXTable5;
    private org.jdesktop.swingx.JXTable jXTable6;
    private org.jdesktop.swingx.JXTextField jXTextField23;
    private org.jdesktop.swingx.JXTextField jXTextField24;
    private org.jdesktop.swingx.JXTextField jXTextField25;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel1;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel10;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel14;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel16;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel17;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel2;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel3;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel4;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel5;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel6;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel7;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel8;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel9;
    private org.jdesktop.swingx.JXTree jXTree1;
    private javax.swing.JLabel lbBaoCao;
    private javax.swing.JLabel lbBenhAn;
    private javax.swing.JLabel lbCauHinh;
    private javax.swing.JLabel lbDanhMuc;
    private javax.swing.JLabel lbNhapKho;
    private javax.swing.JLabel lbThanhToan;
    private javax.swing.JLabel lbThoat;
    private javax.swing.JLabel lbTiepNhan;
    private javax.swing.JPanel panelLogin;
    private javax.swing.JTabbedPane tabParent;
    private org.jdesktop.swingx.JXTable tblDiagnosis;
    private org.jdesktop.swingx.JXTable tblPatients;
    private org.jdesktop.swingx.JXTable tblTreatmentPatients;
    private org.jdesktop.swingx.JXTable tblTreatmentPrescription;
    private org.jdesktop.swingx.JXTable tblWorkerMain;
    private org.jdesktop.swingx.JXTable tblWorkerSearchResult;
    private org.jdesktop.swingx.JXTextField txtDiagnosisName;
    private javax.swing.JPasswordField txtPassword;
    private javax.swing.JTextField txtPatientAddressReception;
    private javax.swing.JTextField txtPatientAgeReception;
    private javax.swing.JTextField txtPatientIdCardReception;
    private javax.swing.JTextField txtPatientIdReception;
    private javax.swing.JTextField txtPatientNameReception;
    private javax.swing.JTextField txtPatientPhoneReception;
    private javax.swing.JTextField txtPatientRelativeReception;
    private javax.swing.JTextField txtPatientWeightReception;
    private javax.swing.JTextField txtSearchPaId;
    private javax.swing.JTextField txtSearchPaIdCard;
    private javax.swing.JTextField txtSearchPaName;
    private javax.swing.JTextField txtSearchPaYear;
    private javax.swing.JTextField txtTreatmentAdvice;
    private javax.swing.JLabel txtTreatmentCost;
    private javax.swing.JTextField txtTreatmentId;
    private javax.swing.JLabel txtTreatmentMedCost;
    private javax.swing.JTextField txtTreatmentPaAddress;
    private javax.swing.JTextField txtTreatmentPaDOB;
    private javax.swing.JTextField txtTreatmentPaName;
    private javax.swing.JTextField txtTreatmentPaPhone;
    private javax.swing.JTextField txtTreatmentPaRelative;
    private javax.swing.JTextField txtTreatmentSearchPaIdCard;
    private javax.swing.JTextField txtTreatmentSearchPaName;
    private javax.swing.JTextField txtTreatmentSearchPaYear;
    private javax.swing.JTextField txtTreatmentSymptom;
    private javax.swing.JTextField txtUserName;
    private org.jdesktop.swingx.JXTextField txtWorkerId;
    private org.jdesktop.swingx.JXTextField txtWorkerMainAddress;
    private org.jdesktop.swingx.JXTextField txtWorkerMainId;
    private org.jdesktop.swingx.JXTextField txtWorkerMainIdCard;
    private org.jdesktop.swingx.JXTextField txtWorkerMainName;
    private org.jdesktop.swingx.JXTextField txtWorkerMainPass;
    private org.jdesktop.swingx.JXTextField txtWorkerMainPhone;
    private org.jdesktop.swingx.JXTextField txtWorkerMainUser;
    private org.jdesktop.swingx.JXTextField txtWorkerName;
    private org.jdesktop.swingx.JXTextField txtWorkerYear;
    // End of variables declaration//GEN-END:variables
}
